I am using Access as a front end for my application and SQL server as the back end database.
I created a LOGON form with the following sub procedures. When I double click on the ADP file to launch my
Access application, the following line is highlighted in the Form_Open paragraph:
-----------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboEmp.SetFocus<----- line his highlighted in yellow
End Sub
-----------------------------------------------------------
I get the message: Runtime error '2105
You can't go to the specified record
Any idea on what causes this error to occur and how to avoid it ?
-----------------------------------------------------------
The full LOGON FORM sub procedures are as follows:
Private intLogonAttempts As Integer
Public USERRIGHTSM As String
Private Sub Command7_Click()
On Error GoTo Err_Command7_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click
End Sub
Private Sub bDisableBypassKey_Click()
'Assign this to the OnClick event of a command button (or double-click event
'of a label or graphic) named "bDisableBypassKey"
'Change the "TypeYourBypassPasswordHere" default password to your password
On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key the programmer's password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
If strInput = "zimmermj" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
"The Shift key will allow the users to bypass the startup options the next time the database is opened.", _
vbInformation, "Set Startup Properties"
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
"The Bypass Key was disabled." & vbCrLf & vbLf & _
"The Shift key will NOT allow the users to bypass the startup options the next time the database is opened.", _
vbCritical, "Invalid Password"
Exit Sub
End If
Exit_bDisableBypassKey_Click:
Exit Sub
Err_bDisableBypassKey_Click:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub
Private Sub cboEmp_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub
Private Sub cmdLogin_Click()
'Check to see if data is entered into the userName combo box
If IsNull(Me.cboEmp) Or Me.cboEmp = "" Then
MsgBox "You must enter a Keberos ID.", vbOKOnly, "Required Data"
Me.cboEmp.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password", vbOKOnly, "Required Data"
Me.cboEmp.SetFocus
Exit Sub
End If
'Check value of password in tblSecurity to see if this matches value chosen in combo box
'If Me.txtPassword.Value = DLookup("PASSWORD", "tblSecurity", "[KERBEROS]=" & Me.cboEmp.Value) Then
If Me.txtPassword.Value = DLookup("PASSWORD", "tblSecurity", "[USERID]=" & Me.cboEmp.Value) Then
strUSER = DLookup("KERBEROSID", "tblSecurity", "[USERID]=" & Me.cboEmp.Value)
strUSERRIGHTS = DLookup("RIGHTS", "tblSecurity", "[USERID]=" & Me.cboEmp.Value)
USERRIGHTSM = strUSERRIGHTS
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmCustomRpt"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times
'database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Private Sub Command8_Click()
Application.Quit
End Sub
Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboEmp.SetFocus
End Sub
Private Sub Command10_Click()
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmLogonNew"
End Sub
I created a LOGON form with the following sub procedures. When I double click on the ADP file to launch my
Access application, the following line is highlighted in the Form_Open paragraph:
-----------------------------------------------------------
Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboEmp.SetFocus<----- line his highlighted in yellow
End Sub
-----------------------------------------------------------
I get the message: Runtime error '2105
You can't go to the specified record
Any idea on what causes this error to occur and how to avoid it ?
-----------------------------------------------------------
The full LOGON FORM sub procedures are as follows:
Private intLogonAttempts As Integer
Public USERRIGHTSM As String
Private Sub Command7_Click()
On Error GoTo Err_Command7_Click
Screen.PreviousControl.SetFocus
DoCmd.DoMenuItem acFormBar, acEditMenu, 10, , acMenuVer70
Exit_Command7_Click:
Exit Sub
Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click
End Sub
Private Sub bDisableBypassKey_Click()
'Assign this to the OnClick event of a command button (or double-click event
'of a label or graphic) named "bDisableBypassKey"
'Change the "TypeYourBypassPasswordHere" default password to your password
On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key the programmer's password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
If strInput = "zimmermj" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
"The Shift key will allow the users to bypass the startup options the next time the database is opened.", _
vbInformation, "Set Startup Properties"
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
"The Bypass Key was disabled." & vbCrLf & vbLf & _
"The Shift key will NOT allow the users to bypass the startup options the next time the database is opened.", _
vbCritical, "Invalid Password"
Exit Sub
End If
Exit_bDisableBypassKey_Click:
Exit Sub
Err_bDisableBypassKey_Click:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub
Private Sub cboEmp_AfterUpdate()
'After selecting user name set focus to password field
Me.txtPassword.SetFocus
End Sub
Private Sub cmdLogin_Click()
'Check to see if data is entered into the userName combo box
If IsNull(Me.cboEmp) Or Me.cboEmp = "" Then
MsgBox "You must enter a Keberos ID.", vbOKOnly, "Required Data"
Me.cboEmp.SetFocus
Exit Sub
End If
'Check to see if data is entered into the password box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password", vbOKOnly, "Required Data"
Me.cboEmp.SetFocus
Exit Sub
End If
'Check value of password in tblSecurity to see if this matches value chosen in combo box
'If Me.txtPassword.Value = DLookup("PASSWORD", "tblSecurity", "[KERBEROS]=" & Me.cboEmp.Value) Then
If Me.txtPassword.Value = DLookup("PASSWORD", "tblSecurity", "[USERID]=" & Me.cboEmp.Value) Then
strUSER = DLookup("KERBEROSID", "tblSecurity", "[USERID]=" & Me.cboEmp.Value)
strUSERRIGHTS = DLookup("RIGHTS", "tblSecurity", "[USERID]=" & Me.cboEmp.Value)
USERRIGHTSM = strUSERRIGHTS
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmCustomRpt"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
'If User Enters incorrect password 3 times
'database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
Private Sub Command8_Click()
Application.Quit
End Sub
Private Sub Form_Open(Cancel As Integer)
'On open set focus to combo box
Me.cboEmp.SetFocus
End Sub
Private Sub Command10_Click()
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmLogonNew"
End Sub