need help with a before update event.

Jon123

Registered User.
Local time
Today, 15:51
Joined
Aug 29, 2003
Messages
668
I'm having some trouble with a before update event. I'm trying to prevent incomplete records so on the before update event I have this code.
So I can catch the null in the step, I get the error msg, I can get the undo so step88 has no data but I cant move the focus to the field that needs data. I get an error something about the record needs to be saved before i can move the focus. Any help

Code:
Private Sub Step88_BeforeUpdate(Cancel As Integer)
        If Nz(Me.step16) <> "" Then
           MsgBox " Incomplete data on page 4. Please update the chamber condition step."
           Cancel = True
           Me.step88.Undo
           me.step16.setfocus 
       Else
        Stop
        End If
 End Sub
 
I always have trouble with me.undo, etc

I use this, although they say sendkeys is deprecated

Cancel = True
sendkeys "{esc}"
 
I cant use the sendkeys because the esc key is turned off on this tab form. Any other ideas?
 
Try by moving it to the After update event and then use DoCmd.RunCommand acCmdUndo
Code:
Private Sub Step88_AfterUpdate()
        If Nz(Me.step16) <> "" Then
           MsgBox " Incomplete data on page 4. Please update the chamber condition step."
           DoCmd.RunCommand acCmdUndo
           Me.step16.SetFocus
       Else
        Stop
       End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom