RE: Help! Access 2007 Login form problem



Now the login form is generating the following error if you don't tab
throught the three form fields first:

Run time error 3164. Field cannot be updated.

It highlights the following from the login code: UserID =
Me.cboCurrentUser.Value

Here is the code:

Option Compare Database

Private Sub Auto_Title0_Click()
'After selecting username set focus to password field
Me.txtPassword.SetFocus
End Sub

Private Sub cboCurrentUser_AfterUpdate()
'After selecting User name set focus to password field
Me.txtPassword.SetFocus
End Sub

Private Sub cboCurrentUser_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box

If IsNull(Me.cboCurrentUser) Or Me.cboCurrentUser = "" Then
MsgBox "You must enter your User Name.", vbOKOnly, "Required Data"
Me.cboCurrentUser.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 your password.", vbOKOnly, "Required data"
Me.txtPassword.SetFocus
Exit Sub
End If

'Check Value of password in tblUsers to see if this
'matches value chosen in combo box

If Me.txtPassword.Value = DLookup("strUserPswd", "Users", _
"[UserID]=" & Me.cboCurrentUser.Value) Then

UserID = Me.cboCurrentUser.Value (This is the line indicated from
debugger)

'Close login form and open Instructor Input form
DoCmd.Close acForm, "Logon", acSaveNo
DoCmd.OpenForm "Instructor Input"

Else
MsgBox "Invalid Password. Please Try Again", vbOKOnly, _
"Invalid Entry!"
Me.txtPassword.SetFocus
End If

'If User enters incorrct password 3 times the database will shut down

intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Contact the database
Administrator.", vbCritical, _
"Restricted Access!"
Application.Quit
End If

End Sub

Private Sub cmdLogin_DblClick(Cancel As Integer)

End Sub

Private Sub Detail_Click()

End Sub

Private Sub Form_AfterUpdate()

End Sub

Private Sub Form_Load()

End Sub

Private Sub Form_LostFocus()

End Sub

Private Sub Form_OnConnect()

End Sub

Private Sub Form_Open(Cancel As Integer)

End Sub

Private Sub Form_Unload(Cancel As Integer)

End Sub

Private Sub Form_ViewChange(ByVal Reason As Long)

End Sub


Also, there are no tabs available on my tables when they are selected, so no
save option, close option, design view etc.

Thanks for any help,
Billiam

"Ken Warthen" wrote:

Billiam,

Is this login form something you created? You mentioned having a years
worth of backups. Does this mean the database was originally created in a
prior version of Access? You might try creating a new login form from
scratch and see if it has the same issues.

"Billiam" wrote:

Hi,

I have a login form which has suddenly started behaving oddly. Not only
that, but every prior version (I backup regularly, so a years worth of
versions) is also acting oddly. What is happening is the login name is chosen
form a drop down list, the password gets entered and you hit the login button
to launch a new form and lose the login screen. The problem is, the Login
comand button does not launch unless you tab through the three items twice
and then hit the login comand button. I am assuming that I have changed
something in the Access Programs Preferences as it applies to all my previous
forms which were acting perfectly. Please help!
Billiam

.


Loading