If a user decides to not enter anything, it keeps throwing errors (my exceptions to prevent null fields from being entered).
The first control is a combobox that is the FK in the table, and the rest of the fields are just fields in the table (name, DOB, etc).
If I wanted to clear all fields so the user can exit the form without saving anything to the table, how can I perform this?
I tried Me.Combbox.Clear (clear isn't an available method), Me.Combobox.Text = "", etc.
Here is the code:
Expand|Select|Wrap|Line Numbers
- Me.EmployeeID = Null
- Me.EmployeeID.SetFocus
- Me.EmployeeID.ListIndex = -1
- If IsNull(Me.EmployeeID.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- ElseIf IsNull(Me.BenFirstName.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- ElseIf IsNull(Me.BenLastName.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- ElseIf IsNull(Me.BenSSN.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- ElseIf IsNull(Me.BenStreet.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- ElseIf IsNull(Me.BenCity.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- ElseIf IsNull(Me.BenState.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- ElseIf IsNull(Me.BenZip.Value) = False Then
- MsgBox ("Please delete all fields or press escape.")
- Else
- DoCmd.Close
- DoCmd.OpenForm "Home"
- End If
When the user goes to delete the text in a field, it also throws the error, which is very annoying.
Any ideas? Thanks.