The dumbing down of America is most evident in the slow decay of substantive content in the enormously influential media... credulous presentations on pseudoscience and superstition... a kind of celebration of ignorance
HELP! I have typed the code as follows (7:35 in tutorial) but when I test it with the correct pairing of Username and Password, I get "Runtime Error 94" Invalid use of Null and the debug takes me to the X= line of code.
I am using Access 2010 - should that make a difference?
My code reads: Private Sub Login_Click() If IsNull(txtUsername) Then MsgBox "Invalid UserName" Exit Sub End If If IsNull(txtPassword) Then MsgBox "Invalid Password" Exit Sub End If
Dim X As Long X = DLookup("UserID", "UserT", "UserName='" & txtUsername & "'AND Password='" & txtPassword & "'")
MsgBox X DoCmd.Close acForm, "LoginF"
End Sub
Reply from Richard Rost:
I used 2007 in the class, and the two are pretty much identical, but DLOOKUP can sometimes throw up errors like this. Just enclose it inside of some error handling:
Dim X As Long X = "" on error resume next X = DLookup("UserID", "UserT", "UserName='" & txtUsername & "'AND Password='" & txtPassword & "'") on error goto 0
That will turn off the error message, and X will remain "" if nothing was looked up.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.