Need help with DLookup for Password Validation

Background - I am new to MSAccess and have no background in VB code.

I have table "tbl_Employee" which contains a persons initials and PIN (password) and a form that contains ticket information .

I have a form (TEST_LOGIN)  that the user enters information about a ticket then enters his initials.
A pop-up Modal form (TEST_POPUP) prompts them for a PIN (password).  When the user clicks "OK", I have the "On-Click"  event run the Macro that is included in the code section below.

Are my references ok for the forms?  Am I able to pass this infromation from my forms to the DLookup command?

Thanks - Kevin


I created a macro that is attached to the "OK" button of the  

DLookUp("[EmpPIN]","[tbl_Employee]","[EmpInitials]='" & [Forms]![TEST_LOGIN]![CR_TECH] & "'")="'" & [Forms]![TEST_POPUP]![T_EmpPIN] & "'"

Open in new window

ktsCatalystAsked:
Who is Participating?
 
peter57rConnect With a Mentor Commented:
I suggest you add a temporary msgbox to your macro to display what is happening.

set the message as:
=DLookUp("[EmpPIN]","[tbl_Employee]","[EmpInitials]='" & [Forms]![TEST_LOGIN]![CR_TECH] & "'")
0
 
peter57rCommented:
Looks OK, although in my head PIN implies a number - and if EmpPIN is a number you don't want the single quotes around the [Forms]![TEST_POPUP]![T_EmpPIN]
0
 
ktsCatalystAuthor Commented:
I have a message attached to this as the Action.  It doesn't matter if the PIN is correct or not, nothing happens.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
peter57rCommented:
Sorry - I don't understand what you are telling me.
Where exactly have you placed this expression?
0
 
ktsCatalystAuthor Commented:
I have this expression placed as a Macro condition. If it is true, it should display a message.  I may change this logic later, but I'm just testing to see if it works at this point.

The sequence is: in the TEST_LOGIN form, the CR_TECH field accepts the users INITIALS and runs a macro to open the TEST_POPUP screen (when there is a change (event, ON CHANGE)).

TEST_POPUP form prompts user for PIN (or password, the PIN is a text field).
When the user clicks "OK" button, a Macro runs to check validity (the DLookup) code.

I expected the MSGBox action to display a message when successful.  I am not getting any type of message, so I am guessing that my DLookup is not successful.
0
 
ktsCatalystAuthor Commented:
Reply,
Peter57r, That is returning the correct value for the PIN.
I then looked at the TEST_POPUP field (it was also  correct)

My error, after reevaluating the original is that the last section of the DLookup after the "=" should not have any quotes around it.  It now works as  I intended.  

What are the rules when adding single  or double quotes?
0
 
peter57rCommented:
Re-read my first response.
0
 
ktsCatalystAuthor Commented:
Thanks for your timely response and excellent help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.