Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with OnChange Event

Status
Not open for further replies.

topdesk123

Programmer
Sep 27, 2001
76
0
0
US
Good morning!

In the Time Card form, users can choose an employee from a drop down box and enter theri time card details. I have the following code setup in case a user accidentally begins to overwrite an exiting record:

Private Sub EmployeeID_Change()
On Error GoTo EmployeeID_Change_Err

If Not IsNull(Me![EmployeeID]) Then
MsgBox "YOU ARE ABOUT TO CHANGE AN EXISTING RECORD!", vbOKCancel
Me.Undo
End If

EmployeeID_Change_Exit:
Exit Sub

EmployeeID_Change_Err:
MsgBox Err.Description
Resume EmployeeID_Change_Exit
End Sub

The problem is, when adding a NEW record using the mouse to choose the employee from the drop down, the error message pops up and the record can't be added. It doesn't however, pop up when you enter the employee using the keyboard. Anyone have any ideas?

TIA
topdesk
 
How about:
Code:
...
If Not IsNull(Me![EmployeeID]) And Me.NewRecord Then
...
 
Close! This worked: If Not IsNull(Me![EmployeeID]) And Not Me.NewRecord Then

Thanks so much!! : )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top