Dlookup Qustion

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have database that is public access but needs some features accessed only
by certain people.

I have created a table (called tblApprovalTable) which has the following
fields, as well as others.

Pin
PassName
SecurityLevel

I have created a form that is displayed when the protected options are
selected asking the user to enter their Passname and Pin which i then want to
check against the Approval Table.
On the 'OK' button I have the following code.

Person = Me.Text2 'Put the entered Passname into a variable
Code = Me.Text4 'Put the entered PIN code into a variable
Pincode = DLookup("[Pin]", "[TblApprovalTable]", "[PassName]" = Person)

The problem is that the variable called Pincode is being returned empty, so
the rest of the routine doesn't work.
I've not had any experience of using variables in Dlookup statements before,
so I suspect that there's something wrong with the last bit where I've used
the 'Person' variable.
I can't find any help searching anywhere else, so if anyones got any clues
then you might just save my sanity.

Thanks in advance

Neil
 
Neil,

The problem is the syntax of the Where clause; change the line of code to:

Pincode = DLookup("[Pin]", "[TblApprovalTable]", "[PassName] = '" _
& Person & "'")

(you can remove the undersore and keep it all in one line, I didn't
because it would most likely wrap in your newsreader).

HTH,
Nikos
 
Thanks Nikos, it worked perfectly.
I knew it was something to do with the variable name, just couldn't work out
the syntax around it but it's all clear to me now!!

Neil

Nikos Yannacopoulos said:
Neil,

The problem is the syntax of the Where clause; change the line of code to:

Pincode = DLookup("[Pin]", "[TblApprovalTable]", "[PassName] = '" _
& Person & "'")

(you can remove the undersore and keep it all in one line, I didn't
because it would most likely wrap in your newsreader).

HTH,
Nikos
I have database that is public access but needs some features accessed only
by certain people.

I have created a table (called tblApprovalTable) which has the following
fields, as well as others.

Pin
PassName
SecurityLevel

I have created a form that is displayed when the protected options are
selected asking the user to enter their Passname and Pin which i then want to
check against the Approval Table.
On the 'OK' button I have the following code.

Person = Me.Text2 'Put the entered Passname into a variable
Code = Me.Text4 'Put the entered PIN code into a variable
Pincode = DLookup("[Pin]", "[TblApprovalTable]", "[PassName]" = Person)

The problem is that the variable called Pincode is being returned empty, so
the rest of the routine doesn't work.
I've not had any experience of using variables in Dlookup statements before,
so I suspect that there's something wrong with the last bit where I've used
the 'Person' variable.
I can't find any help searching anywhere else, so if anyones got any clues
then you might just save my sanity.

Thanks in advance

Neil
 
Welcome!
Thanks Nikos, it worked perfectly.
I knew it was something to do with the variable name, just couldn't work out
the syntax around it but it's all clear to me now!!

Neil

:

Neil,

The problem is the syntax of the Where clause; change the line of code to:

Pincode = DLookup("[Pin]", "[TblApprovalTable]", "[PassName] = '" _
& Person & "'")

(you can remove the undersore and keep it all in one line, I didn't
because it would most likely wrap in your newsreader).

HTH,
Nikos
I have database that is public access but needs some features accessed only
by certain people.

I have created a table (called tblApprovalTable) which has the following
fields, as well as others.

Pin
PassName
SecurityLevel

I have created a form that is displayed when the protected options are
selected asking the user to enter their Passname and Pin which i then want to
check against the Approval Table.
On the 'OK' button I have the following code.

Person = Me.Text2 'Put the entered Passname into a variable
Code = Me.Text4 'Put the entered PIN code into a variable
Pincode = DLookup("[Pin]", "[TblApprovalTable]", "[PassName]" = Person)

The problem is that the variable called Pincode is being returned empty, so
the rest of the routine doesn't work.
I've not had any experience of using variables in Dlookup statements before,
so I suspect that there's something wrong with the last bit where I've used
the 'Person' variable.
I can't find any help searching anywhere else, so if anyones got any clues
then you might just save my sanity.

Thanks in advance

Neil
 
Back
Top