Link to home
Start Free TrialLog in
Avatar of Michael Dean
Michael DeanFlag 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
Avatar of als315
Flag of Russian Federation image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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....
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.