Empty Record being created

seamus9909 used Ask the Experts™
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
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can add "Required" property to any field in your table. After this you will get an error when empty record will be added. Select "debug" and you will see code, where record is added. You can use "On error resume next". In this case record will be not added to table with required field
John TsioumprisSoftware & Systems Engineer

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 - Microsoft Access MVP)Database Architect / Application Developer
Top Expert 2007

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 ?
Distinguished Expert 2017

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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial