I have a conuncrum

S

scubadiver

In the "before update" event of a form I have

me.undo

to clear the form if not all the fields are entered (most are required). I
also have a new query button which has

DoCmd.GoToRecord , , acNewRec

in the "on click" event.

If I fill out all the fields and press the button an error message comes up
that states I can't go to a new record. I guess the "me.undo" is activated so
it can't go to a new record.

Any ideas on how I can resolve this?

cheers
 
S

Sprinks

I don't know how to avoid the situation keeping the current code, but why
force the user to reenter all of the fields just because they skipped one or
more?

' Better (IMO) BeforeUpdate code
Dim ctl as Control
For Each ctl in Me.Controls
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
' Include other enterable control types as needed
If Nz(ctl.Value)=0 Then
MsgBox ctl.Name & " is a required field. Please enter a
value."
ctl.SetFocus
Cancel = True
Exit For
End If
Next ctl
 
Top