finding info in another table

bloody_football

Registered User.
Local time
Tomorrow, 04:37
Joined
Sep 8, 2004
Messages
70
Please note that I am self taught (90% of what I have learnt has been off these boards!). I did make this form with info I found on this forum.
I am having problems with a log in box for a database, the line of code is -
Code:
If Me.txtpassword.Value = DLookup("password", "customers", "[customerID] =" & Me.EbayName.Value) Then
This code is in a Form; "password" is the value in the table of "customers"; [customerID] is the primary key value I wish to remember; Me.EbayName.Value I assume is the value in the table that access is looking for.

Questions -
A) It is not looking up the value for [customerID] - what have I done wrong?

B) In the line of Me.EbayName.Value what does the 'Me.' part tell Access to do? I assume it's a pointer to it's own form? What part of the line do I need to change to make it point to another form (or table)?

C) When this is finished how do I get the program to remember the 'customerID' while the customer is fillling out other forms?

James
 
Hi James,

Your syntax looks OK, if CustomerID is numeric.

I'd add the Nz function because the DLookUp might return a Null if no match,
and you can't assign that to a VBA string.

Code:
If Me.txtpassword = Nz(DLookup("password", "customers", "[customerID] =" & Me.EbayName), "") Then

A) It is not looking up the value for [customerID] - what have I done wrong?
It looks OK, if Me.EbayName is a string, then you need single-quote delimiters:

Code:
If Me.txtpassword = Nz(DLookup("password", "customers", "[customerID] = '" & Me.EbayName & "'"), "") Then

B) In the line of Me.EbayName.Value what does the 'Me.' part tell Access to do?
I assume it's a pointer to it's own form?
What part of the line do I need to change to make it point to another form (or table)?

"Me." is loosely a way of referring to the objects within a form.
If, instead of Me.EbayName (say it was on another form), use Forms![SomeForm]![EbayName]

C) When this is finished how do I get the program to remember the 'customerID'
while the customer is filling out other forms?
You can store the value in a Textbox on your form and refer to it like in question B.

hth,
Wayne
 

Users who are viewing this thread

Back
Top Bottom