DLookup for Unbound CheckBox

burrina

Registered User.
Local time
Today, 12:10
Joined
May 10, 2014
Messages
972
Having a Senior Moment!

On my Login form I am trying to get the status of a user. Form and checkbox are unbound.

tblUserSecurity_Sec
userID is the UserName.
Field (Active) Data Type is Number, Field Size is Integer

CheckBox is (chkactive)


If DLookup("[Active]", "tblUserSecurity_Sec") = -1 And [userID] = (Me.txtUserID) Then
Me.chkactive = -1
End If

Thanks for your time.
 
Thanks, but that does not help. I can get the value of Active but not if I add the matching userID . Simple, I know but frustrating.
 
Did you look at the examples in the link? The way the DLookup is constructed in those examples are different from yours. Please read the examples.
 
I have spent hours on this simple thing with every combination to make it work.

Thanks Anyway. YES, I read that a LONG time ago.
 
Still no luck?

Ok, let's look at your code and go through it. tblUserSecurity_Sec is your table right? And the UserID field is a text field containing the user ID you're checking against?

What is the -1 in your code supposed to mean?
 
-1 means the users active status is Active. 0 is InActive.
 
I'm talking about the -1 in the DLookup() line of your code. What were you trying to do there?
Code:
If DLookup("[Active]", "tblUserSecurity_Sec")[B][COLOR="Red"] = -1[/COLOR][/B] And [userID] = (Me.txtUserID) Then
 
If the users status is Active (-1) and the userID (UserName) matches txtUserID (UserName) then check off the check box chkactive.
 
Re-construct your code along the lines of:
Code:
If DLookup("Active", "tblUserSecurity_Sec", "userID = '" &  Me.txtUserID & "'") And Me.chkactive = -1 Then
    Msgbox "I'm active"
End If
Test it using a Msgbox as above.
 
This worked.

If DLookup("Active", "tblUserSecurity_Sec", "userID = '" & Me.txtUserID & "'") And Me.txtstatus = -1 Then
Me.chkactive = -1
End If


Thanks for you help and patience.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom