TheWanderer
New member
- Local time
- Today, 13:22
- Joined
- Feb 3, 2013
- Messages
- 7
I have a lovely bit of code I use as a login for databases. I didn't write it, I found it on the internet. It used to work fine, but now that I have Access 2010, it doesn't like it and gives me a run time error.(run-time error 3314 You must enter a value in the 'TableEmployees.EmployeeID' field. Does anyone know what I should change the code to, in order for it to work? It says it doesn't like the Me.Dirty=False line but apparently it is a known fault.
The reason I liked this code so much, is that the users can set their passwords on their first use of the database and if they forget it, it's easy enough to delete it and they can start again.
Any help would be much appreciated, I have spent hours on this so far.
The reason I liked this code so much, is that the users can set their passwords on their first use of the database and if they forget it, it's easy enough to delete it and they can start again.
Any help would be much appreciated, I have spent hours on this so far.
Code:
Option Compare Database
Private Sub ChooseEmployee_AfterUpdate()
Filter = "(((TableEmployees.EmployeeID)=[Forms]![FormChooseEmployee]![ChooseEmployee]))"
FilterOn = True
[Password1] = Null
[Password2] = Null
[OK].Enabled = True
[Password1].Visible = True
[Password1].SetFocus
If [Forms]![FormChooseEmployee]![ChooseEmployee].Column(2) = "" Then
[Password2].Visible = True
MsgBox "Please set your password by entering it in both the fields shown.", vbOKOnly
Else
[Password2].Visible = False
End If
End Sub
Private Sub Exit_Click()
DoCmd.Quit
End Sub
Private Sub Form_Open(Cancel As Integer)
Filter = "False"
FilterOn = True
End Sub
Private Sub OK_Click()
If IsNull([Password1]) Then MsgBox "Enter a password.", vbOKOnly: [Password1].SetFocus: Exit Sub
If [Password2].Visible = True Then
If [Password1] = [Password2] Then
[Password] = [Password1]
Me.Dirty = False
MsgBox "You must restart the application.", vbOKOnly: DoCmd.Quit
Else
MsgBox "Passwords do not match, please enter again.", vbOKOnly
[Password1] = Null
[Password2] = Null
[Password1].SetFocus
Exit Sub
End If
Exit Sub
End If
If [Password1] = [Password] Then
[Password1].Visible = False
[Password1] = Null
Modal = False
DoCmd.OpenForm "FormChooseEmployee", , , , , acHidden
DoCmd.OpenForm "menu"
'Use the employee authorisation levels (see table) to enable or disable various buttons on the Switchboard
If [CROwner] = True Then
Forms![menu]![Proc].Enabled = True
Else
Forms![menu]![Proc].Enabled = False
End If
Else
MsgBox "Incorrect password.", vbOKOnly
[Password1] = Null
[Password1].SetFocus
End If
End Sub