Warning: newbie
I've already posted this in the wrong area, sorry. Anywho...
I'm trying to design a table around a dlookup statement I have.
I'm having trouble putting it all together.
strName = Forms!login1.Login 'a selected name at login from dropdown
menu
strPassword = Me![Password]
If StrComp(Nz(DLookup("[Password]", "UserDef", "User_Name ='" & strName &
"'"), ""), strPassword, 0) = 0 Then
If I understand this, I need a field called Password in Table UserDef ...
after that I'm lost.
Where do I put my criteria?
How?
Please give absurdly detailed answer.

Signature
I reject your reality and substitute my own.
Promote hydrogen - one of the best "clean" fuels there are!
Steve Schapel - 04 Nov 2005 19:07 GMT
Jsc3489,
I think you probably want this...
If DLookup("[Password]", "UserDef", "User_Name ='" & Me.Login & "'") =
Me.Password Then
So, your UserDef table has 2 fields, User_Name and Password. And the
form from which this code is being called has an unbound combobox called
Login, for the selection of the user name, and an unbound textbox called
Password for the entry of the user's password. And I would guess the
rest of the code might look something like this...
If Me.Password = DLookup("[Password]", "UserDef", "User_Name ='" &
Me.Login & "'") Then
DoCmd.OpenForm "YouCanDoSomethingNow"
Else
MsgBox "Invalid password"
Me.Password = Null
End If
At the risk of adding confusion, an alternative approach would be to
include both columns of the UserDef table in the Row Source of the Login
combobox. In this case, the Properties of the combobox get set like this...
Column Count: 2
Bound Column: 1
Column Widths: x;0
(where x is the number that is wide enough to show the user names
in the drop-down list)
... and then you can dispense with the DLookup function, in favour of...
If Me.Password = Me.Login.Column(1)

Signature
Steve Schapel, Microsoft Access MVP
> Warning: newbie
> I've already posted this in the wrong area, sorry. Anywho...
[quoted text clipped - 14 lines]
> How?
> Please give absurdly detailed answer.