Matcc

D

Darren

Hi. I am hoping someone can help me, with what may be a basic question.

I have a table which contains 2 fields - passwords and access levels. I
want to create a password login form, which then checks the entered password
against the table. If it matches a password in the table, I need to return
the access level value from that record, back to the form. I am unsure of the
code I need to use to check the table for a match to the entered password,
and the return another value back to the form.

If anyone could help me, I would be very grateful.

Thanks in advance,

Darren
 
D

Darren

Applogies, this sent accidentally whilst i was typing in the title. The title
should be "Matching a value from a for in a table"
 
D

Dirk Goldgar

Darren said:
Hi. I am hoping someone can help me, with what may be a basic
question.

I have a table which contains 2 fields - passwords and access
levels. I want to create a password login form, which then checks the
entered password against the table. If it matches a password in the
table, I need to return the access level value from that record, back
to the form. I am unsure of the code I need to use to check the table
for a match to the entered password, and the return another value
back to the form.

You can use the DLookup() function to do this quite easily. For
example,

Dim varAccessLevel As Variant

AccessLevel = _
DLookup("AccessLevel", "PasswordTable", "Password=" & _
Chr(34) & _
Replace(Me!Password, """", """""") & _
Chr(34))

If IsNull(varAccessLevel) Then
MsgBox "You entered an invalid password!"
Else
Me!AccessLevel = varAccessLevel
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top