T
Tara
All of our databases have Login forms. I've reused these forms and the
associated tables many times in the past with other databases (the original
Login form was part of a database that already existed before I started
working here). Now, for the first time, I'm having a problem with it.
Obviously, the code indicates that the variable isn't defined, so I defined
it. Unfortunately, it then just goes on to the next Case statement, and
breaks there. In looking at our other databases, I realized that the
variables aren't defined in those either, at least not that I can see, and
they work perfectly. I'm not proficient at all with coding, and I'm lost
trying to figure out what the underlying issue is. Here's the code
involved...the code originally broke at Case ltNone. Any help is greatly
appreciated!
Private Sub Form_Load()
Dim rst As New ADODB.Recordset
Dim strUser As String
On Error GoTo ErrHandler
rst.Open "SysMisc", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
bUsePasswords = rst.Fields("UsePasswords")
Select Case rst.Fields("Login")
Case ltNone
cmdEnter_Click
Case ltWindows
strUser = GetUser
rst.Close
rst.Open "SELECT * FROM sysEmployees WHERE
sysEmployees.WindowsLogin='" & strUser & "'", CurrentProject.Connection,
adOpenStatic, adLockReadOnly
If rst.RecordCount > 0 Then
Me.comEmployeeID = rst.Fields("EmployeeID")
If bUsePasswords = False Then
cmdEnter_Click
Else
Me.txtPassword.Visible = bUsePasswords
End If
Else
Err.Raise 550, "sysLogin.Form_Load", "Unauthorized access
attempted: " & strUser
rst.Close
Set rst = Nothing
DoCmd.Quit
End If
Case ltDatabase
Me.txtPassword.Visible = bUsePasswords
End Select
rst.Close
ExitHere:
Set rst = Nothing
Exit Sub
ErrHandler:
If Err.Number = 550 Then
MsgBox Err.Description
Application.Quit
Else
MsgBox Err.Description
End If
Resume ExitHere
End Sub
associated tables many times in the past with other databases (the original
Login form was part of a database that already existed before I started
working here). Now, for the first time, I'm having a problem with it.
Obviously, the code indicates that the variable isn't defined, so I defined
it. Unfortunately, it then just goes on to the next Case statement, and
breaks there. In looking at our other databases, I realized that the
variables aren't defined in those either, at least not that I can see, and
they work perfectly. I'm not proficient at all with coding, and I'm lost
trying to figure out what the underlying issue is. Here's the code
involved...the code originally broke at Case ltNone. Any help is greatly
appreciated!
Private Sub Form_Load()
Dim rst As New ADODB.Recordset
Dim strUser As String
On Error GoTo ErrHandler
rst.Open "SysMisc", CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
bUsePasswords = rst.Fields("UsePasswords")
Select Case rst.Fields("Login")
Case ltNone
cmdEnter_Click
Case ltWindows
strUser = GetUser
rst.Close
rst.Open "SELECT * FROM sysEmployees WHERE
sysEmployees.WindowsLogin='" & strUser & "'", CurrentProject.Connection,
adOpenStatic, adLockReadOnly
If rst.RecordCount > 0 Then
Me.comEmployeeID = rst.Fields("EmployeeID")
If bUsePasswords = False Then
cmdEnter_Click
Else
Me.txtPassword.Visible = bUsePasswords
End If
Else
Err.Raise 550, "sysLogin.Form_Load", "Unauthorized access
attempted: " & strUser
rst.Close
Set rst = Nothing
DoCmd.Quit
End If
Case ltDatabase
Me.txtPassword.Visible = bUsePasswords
End Select
rst.Close
ExitHere:
Set rst = Nothing
Exit Sub
ErrHandler:
If Err.Number = 550 Then
MsgBox Err.Description
Application.Quit
Else
MsgBox Err.Description
End If
Resume ExitHere
End Sub