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!

On change event problem

Status
Not open for further replies.

topdesk123

Programmer
Sep 27, 2001
76
0
0
US
Hello All!

I use the following code in time cards when someone tries to change an existing time card:

Private Sub EmployeeID_Change()
On Error GoTo EmployeeID_Change_Err

Dim intAnswer As Integer

If Not IsNull(Me![EmployeeID]) And Not Me.NewRecord Then
intAnswer = MsgBox("You are about to change an existing record. " & Chr(13) & Chr(10) & "Would you like to continue?", vbYesNo + vbQuestion, "Existing Record")
Select Case intAnswer
Case vbYes

MsgBox "Thank you. Please continue", vbOKOnly

Me.EmployeeID.SetFocus
Case vbNo
MsgBox "Thank you. Changes will be cancelled", vbOKOnly, "Entry process continuing."
Me.Undo

End Select
End If

EmployeeID_Change_Exit:
Exit Sub

EmployeeID_Change_Err:
MsgBox Err.Description
Resume EmployeeID_Change_Exit
End Sub

The code works good, except it prompts the user at every keystroke in the field. What am I missing?

TIA
topdesk
 
The Change event will fire for each keystroke. You may find that the Before Update event suits better.
 
Thank you Remou! That works perfectly! Have a great evening!

topdesk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top