Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2011
    Posts
    413

    Unanswered: DLookup for Unbound CheckBox

    I don't know why I am having a hard time with this simple thing.
    I need to make an unbound checkbox on an unbound form (chkactive) True If (Active) which is a yes/no field in tblUserSecurity_Sec is True under these conditions.

    DLookup("[Active]", "tblUserSecurity_Sec", "userID=" & Me.txtUserID.Value" & "'")

    Thanks for the Help!
    Last edited by Burrina; 06-29-14 at 15:36. Reason: Solved

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    DLookup("[Active]", "tblUserSecurity_Sec", "userID=" & Me.txtUserID.Value & "'")

    i could believe...
    what happens if you put a breakpoint on the code
    and then examine the value of Me.txtUserID.Value?
    there's 3 possible outcomes form a dlookup on a boolean column
    true or false as per the value of the column
    or NULL if the column isn't found

    if I were you Id want to prove the dlookup is working and retrieving the expected value(s)
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2011
    Posts
    413
    It says it cant find a field? I tried this to no avail. So in English, if the users status is Active,i.e. = True, then set the checkbox chkactive to True.
    userID is the users name and txtUserID is a textbox.
    If I try it without the userID = txtUserID, it works???
    If DLookup("[Active]", "tblUserSecurity_Sec") = -1 And [userID] = (Me.txtUserID) Then
    Me.chkactive = -1
    End If

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what happens if you put a breakpoint on the code?
    and then examine the value of Me.txtUserID.Value?

    i user id a string/text or a number?
    what column was reported as not found?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Nov 2011
    Posts
    413
    I managed to solve it.
    'Check Users Active Status.
    If DLookup("Active", "tblUserSecurity_Sec", "userID = '" & Me.txtUserID & "'") And Me.txtstatus = -1 Then
    Me.chkactive = -1
    End If

    Many Thanks for the Help.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •