I have a conuncrum

G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top