• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

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

0
ktsCatalyst
Asked:
ktsCatalyst
  • 4
  • 4
1 Solution
 
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
 
peter57rCommented:
Sorry - I don't understand what you are telling me.
Where exactly have you placed this expression?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
peter57rCommented:
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
 
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now