G
Guest
Hellow
I have a copy of Access 2000 and I’m trying to learn access from a book
titled “Access2000 Programming Blue book.
In the following code the Dlookup always return “Rosebudâ€, and “Kane†in
variables Qresult1 and qresult2 respectively. This gives the desired
result that the author is looking for but I don’t understand why these
lookups always return “Rosebud†and “Kane†no matter what I request. It’s
as if these were the only values in the table. What’s going on?
Thanks Glo
Option Compare Database
Sub Logon()
'Variable declaration section
Dim Username
Dim Password
Dim Qresult1
Dim qresult2
'Variable definition section
Username = InputBox( _
"You're programming with Access 2000." & Chr(13) & Chr(13) & _
"Please enter your username.")
Password = InputBox( _
"You're doing a great job!" & Chr(13) & Chr(13) & _
"Now, please enter your password")
'Query execution section
Qresult1 = DLookup("[Username]", "FirstTable", "[Username] = username")
qresult2 = DLookup("[Password]", "FirstTable", "[Password] = password")
'Processing logic section
If Username = Qresult1 And Password = qresult2 Then
MsgBox "Congratulations, Give this man a cigar!"
Else
MsgBox "Hey! That's not right!" & Chr(13) & "No cigar for you!"
End If
End Sub
The tables are as follows:
Username Password FirstEmployeesID
Bruce Batman 30
Shaft JohnShaft 32
Rosebud Kane 22
Fox Mulder
Spiderman Spidey 31
Clark Superman
Fieldname Data type
Username Text
Password Text
FirstEmployeeID number
I have a copy of Access 2000 and I’m trying to learn access from a book
titled “Access2000 Programming Blue book.
In the following code the Dlookup always return “Rosebudâ€, and “Kane†in
variables Qresult1 and qresult2 respectively. This gives the desired
result that the author is looking for but I don’t understand why these
lookups always return “Rosebud†and “Kane†no matter what I request. It’s
as if these were the only values in the table. What’s going on?
Thanks Glo
Option Compare Database
Sub Logon()
'Variable declaration section
Dim Username
Dim Password
Dim Qresult1
Dim qresult2
'Variable definition section
Username = InputBox( _
"You're programming with Access 2000." & Chr(13) & Chr(13) & _
"Please enter your username.")
Password = InputBox( _
"You're doing a great job!" & Chr(13) & Chr(13) & _
"Now, please enter your password")
'Query execution section
Qresult1 = DLookup("[Username]", "FirstTable", "[Username] = username")
qresult2 = DLookup("[Password]", "FirstTable", "[Password] = password")
'Processing logic section
If Username = Qresult1 And Password = qresult2 Then
MsgBox "Congratulations, Give this man a cigar!"
Else
MsgBox "Hey! That's not right!" & Chr(13) & "No cigar for you!"
End If
End Sub
The tables are as follows:
Username Password FirstEmployeesID
Bruce Batman 30
Shaft JohnShaft 32
Rosebud Kane 22
Fox Mulder
Spiderman Spidey 31
Clark Superman
Fieldname Data type
Username Text
Password Text
FirstEmployeeID number