Hello all,
I require some VB coding help if possible.
I have a login screen (frmLogin), where the users enter username / password combination and click an Enter button. The following code is then attributed to the onclick event of that button
Code:
Private Sub cmdEnter_Click()
Dim dbs As CurrentProject
Set dbs = Application.CurrentProject
If txtUser.Value = "Admin" And txtPass.Value = "admin" Then
dbs.Properties(StartUpForm) = "Switchboard"
dbs.Properties(StartUpShowDBWindow) = True
ElseIf txtUser.Value = "Normal" And txtPass.Value = "normal" Then
dbs.Properties(StartUpForm) = "Switchboard"
dbs.Properties(StartUpShowDBWindow) = False
dbs.Properties(AllowFullMenus) = False
dbs.Properties(AllowSpecialKeys) = False
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
End If
End Sub
When I click Enter I get an error message:
"Runtime Error 2467. The expression you entered refers to an object that is closed or doesn't exist"
and when I click debug, it always highlights the first line of each if statement the
Code:
dbs.Properties(StartUpForm) = "Switchboard"
I apologise for what I presume is poor coding, as I am not particulary versed in this type, I am only comfortable with basic selection statement and msg box type programming. Am I right is assuming that some type of object declarations are needed? I also realsise that hardcoding in the username and password is not best practice, but I just want to use these for testing.
If anyone could provide some more assistance that would be great.
Thanks,
nosaj