Required Field

D

Daniel Lees

Hi

I am creating an access database and have a table that has several required
fields, the problem i have is that i have a data entry form on which there is
an ok and cancel button, the ok button saves the record and moves to another
form, filling in some fields from the previous form. The problem i have is
that when i click ok the record doesn't save becuase the required fields
aren't filled in. The macro takes the user away and displays a blank record
on the next form as it didnt' save. How can i get it to show the warnings
about the empty fields before it moves away. I want it to tell them to fill
in the fields rather than not saving.

cheers

Danny
 
A

Allen Browne

What does your Ok button do?

Perhaps it could use the RunCommand action, and in the lower pane of macro
design, choose the command SaveRecord.

If your button simply closes the form without explictly saving you have
encountered this bug:
Losing data when you close a form
at:
http://allenbrowne.com/bug-01.html
 
O

Ofer Cohen

To check if the fields are field you can try

If Isnull(me.FieldName1) Or Isnull(Me.FieldName2) Then
MsgBox "Fields A + B must be filled"
Else
If Me.Dirty Then
Me.Dirty = False ' Save record
End If
Docmd.OpenForm "FormName"
End If
 

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