Saving records in a subform

G

Guest

I am using:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

In a subform under a save button to save a record after an add of a new
record to a table with a primary key that does not allow duplicates. I allow
the user to add more records with a new record button which uses:
DoCmd.GoToRecord , , acNewRec

The subform is closed only when the parent form closes. After adding one or
more records, saving them and closing I always get the error or warning:

“The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries and try again.â€

The form closes OK and the records added are there and do not have duplicate
keys.

My question is why the message? Doesn’t DoCmd save menu call clear the
“dirty†flag? Seems like Access trying to save again at form close.
 
G

George Nicholson

Just a thought...

I'm just thinking that Access has *some* reason to believe that the form has
become dirty since your last save. The fact that Access also considers it to
be a duplicate, makes me think there is some sort of
"clone-this-record-as-a-default" action going on. Access will automatically
try to save new/changed records when you close a form (or move to a new
record). It doesn't require an explicit "Save" command. Maybe it's choking
on some sort of incomplete "template" record that you didn't intend to be
saved anyway?
 

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