Table design?

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

Guest

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.
 
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)
 
Back
Top