Check If User Exist In Table Using DLookup

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • toadmaster
    New Member
    • Aug 2009
    • 45

    Check If User Exist In Table Using DLookup

    I am trying to use the DLookup function to check a table to see if a user exist in there; if not refuse them access. The following is the code I am using but it seems to just pop up the "Error Message" without really referencing the table

    text33 = Environ("userna me")
    Text69 = DLookup("[Forename]&' '&[Surname]", "Users", "[Username] = text33")
    If text33 <> DLookup("[Username]", "Users", "[Username] <> text33") Then
    MsgBox "You Are Not Authorized To Use This Form"
    Else
    If Val(Me.estp) > DLookup("amount authorized", "Users", "UserName = '" & Me.text33 & "'") Then
    MsgBox "Amount Over approval limit, Please Assign to Your Manager"
    Else
    With MailOutLook

    Any help will be appreciated
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    I think what you want here is DCount (as opposed to DLookup)

    something like this:
    Code:
    dim i as integer
    dim Authorized as Boolean
    i = DCount("[Forename]&' '&[Surname]", "Users", "[Username] = text33")
    
    if i > 0 then
    Authorized = true
    else
    Authorized = false
    end if

    Comment

    Working...