Saving a record based on fields

L

Ling

I have a problem here:
I only want to save a record if some fields have some
value entered in them.
What should I use? Would Docmd.save work? I am lost.
Thanx for any help.

Ling
 
A

Allen Browne

1. Open your table in design view.

2. Select a field that must have a value.

3. In the lower pane, set the Required property to Yes.

4. If they are Text type fields, set Allow Zero Length to No.

5. Repeat steps 2 - 4 for the other fields.

6. Save the table.
Access won't let you save the record without values in these fields.

If you need to force a save, DoCmd.Save won't work since this refers to
saving design changes to the form. RunCommand acCmdSaveRecord will save the
record for the form that has focus. My preferred approach is to set the
form's Dirty property, since this specifies the form (whether it has focus
or not), and returns a trappable error if the save failed:
Me.Dirty = False

To check if the record is correct before saving, use the BeforeUpdate event
procedure of your form.
 

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