Avatar of Michael Dean
Michael Dean
Flag for United States of America asked on

Empty Record being created

I have a form where the user will update the recordset, and after closing the form, there is a blank record (other than key) created.

I have looked at the events on the form nothing other than form refreshes being performed.  I can not find any reason why an additional record is created when the user updates an existing record via the form
Microsoft Access

Avatar of undefined
Last Comment

8/22/2022 - Mon

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
John Tsioumpris

Probably you have something "extra" in your code that is "pushing' the empty data....breakpoint/debug your data along with constantly querying the underlying table to see when the empty record is inserted....
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)

Do you have any code in the OnCurrent even?
And if so ... are you setting any 'default values' or otherwise ?

" nothing other than form refreshes being performed"
Can you elaborate ?

Refresh has the side effect of forcing the current record to be saved if it is dirty.  Always use an explicit save command if that is your intention.  The standard is DoCmd.RunCommand acCmdSaveRecord.  An alternate that circumvents a particular problem which I have never encountered is.  Me.Dirty = False.

Given the symptoms, your code is dirtying the record and the Refresh is forcing it to be saved.  I use the method suggested by als.  Setting declarative RI on the table means that regardless of what prompts the update, the database engine will enforce your rules.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy