Help! Access 2007 Login form problem

B

Billiam

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
 
K

Ken Warthen

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.
 
B

Billiam

Sorry Ken, I mean that I have a years worth of copies of the database, ALL of
them are the same version Access 2007. The databse is a work in progress, and
every time i change something I save a copy of the database. That is what has
me so confused, as I sometimes look back at certain versions and everythng
has always worked fine, now the login procedure does not work in any of them,
and I am wondering why. BTW, I have created the login form based on a posted
login procedure which has ALWAYS worked until this week. As I am getting
ready to release the database, I have been playing with the "Access Options"
to see what I can disable for ease and safety...that is why I am wondering if
i have inadvertantly changed something that is having this effect on the
login procedure.

If anyone could advise what would be best to post to enable a solution, it
would be greatly appreciated as the "Big Boss" is coming to see the database
Friday...gulp!
 
B

Billiam

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
 
B

Billiam

Thank you thank you thank you for replying! I just do not understand why this
has worked for a year, and suddenly it doesn't work in the current version OR
52 incremental backup versions...

The login procedure came from databasedev co uk forward slash login html
(insert periods in spaces other than forward slash) and
unfortunately/fortunately, I was able to apply it, but really am not VBA
savvy...

Any suggestions on how to do "error trapping" ???

Thanks for any help I REALLLLLLLLLLLLLLLLY Apreciate it!
Under the wire,
Billiam
AccessVandal via AccessMonster.com said:
Billiam,

Sorry, but I don't see where is the declared variable "UserID". Second I
don't see that you have any error trapping.

You might want to declare the variable in the onclick event...like.

Dim UserID as String
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
 
B

Billiam

Thank you again for your advice. Declaring the variable in the onclick event
did not work on its own. Placing

Dim UserID as String

in the procedure where I was getting the debug error did work. I will
repaste all code in case anyone is interested and trying to learn, as I am!

My question is, were both of these changes required, or was it soley
defining the UserID variable, and regardless of this, WHY was the current
version and 52 incremental backups retroactively affected?

One more thing, when I click on a table to work on it, the table opens, but
there is no tab in the top left corner (to close, design view, form view,
etc) Could this also point to what it is i have screwed up playing around in
the Access Options? Can I reset the Access Options to the default?

MANY THANKS for getting this wirking at
least!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You're the best!
Billiam

AccessVandal via AccessMonster.com said:
Billiam,

Sorry, but I don't see where is the declared variable "UserID". Second I
don't see that you have any error trapping.

You might want to declare the variable in the onclick event...like.

Dim UserID as String
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
 
B

Billiam

Here is the code as it is now:

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
Dim UserID As String
If Me.txtPassword.Value = DLookup("strUserPswd", "Users", _
"[UserID]=" & Me.cboCurrentUser.Value) Then

UserID = Me.cboCurrentUser.Value

'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_Click()
Dim UserID As String 'this is the part that was added thanks to AccessVandal

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


Billiam said:
Thank you again for your advice. Declaring the variable in the onclick event
did not work on its own. Placing

Dim UserID as String

in the procedure where I was getting the debug error did work. I will
repaste all code in case anyone is interested and trying to learn, as I am!

My question is, were both of these changes required, or was it soley
defining the UserID variable, and regardless of this, WHY was the current
version and 52 incremental backups retroactively affected?

One more thing, when I click on a table to work on it, the table opens, but
there is no tab in the top left corner (to close, design view, form view,
etc) Could this also point to what it is i have screwed up playing around in
the Access Options? Can I reset the Access Options to the default?

MANY THANKS for getting this wirking at
least!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
You're the best!
Billiam

AccessVandal via AccessMonster.com said:
Billiam,

Sorry, but I don't see where is the declared variable "UserID". Second I
don't see that you have any error trapping.

You might want to declare the variable in the onclick event...like.

Dim UserID as String
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top