dlookup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mrijet
    New Member
    • Feb 2015
    • 64

    dlookup

    hello..how can I retrieve data for restricted the access level

    here are my code

    Code:
    Form_OnLoad()
    Dim user as string
    
    user = dlookup("UserType","tblUser","EmployeeID=" & [EmployeeID])
    
    if user = "Admin" then
    me.txtdel.visible = True
    elseif user = "user" then
    me.txtdel.visible = false
    endif
    Is this the right code to retrieve data...
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    It looks fine. What happens when you run it?

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      I advise that you pull "EmployeeID =" & [EmployeeID] out of the function, assign it to a variable and use the variable within the function:

      Code:
      '...
      Dim strWhere As String
      '...
      strWhere = "EmployeeID=" & [EmployeeID]
      '
      user = dlookup("UserType","tblUser",strWhere)
      this way if the returned value(s) for strWhere are not resolving correctly you can use the debug.print strWhere to print the resolved string to the immediates window for review.

      Comment

      Working...