I have a mainform and subform. They are both bound to related tables. On the subform I have a button to create a new record. However if after typing in data I change my mind and press an abort button it leaves a blank record in my child table.
I am using:
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.SetWarnings True
In the abort button.
I put two textboxes on the subform which display the primary keys of both tables. Before the record is created the first primary key shows the primary key of the mainform record I had selected, and the second textbox shows (autonumber). As soon as I start typing the second textbox shows the related child table being allocated a primary key, so far so good. However when I press the abort button, a new number appears in the second textbox, and if I hide the subform, and close the database from the now visible mainform I then find its left a blank record in the child table having the primary key value I last saw.
I have debugged to see if another command is made for a new record to be created after aborting but cannot find anything. Any ideas, thanks
I am using:
DoCmd.SetWarnings False
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.SetWarnings True
In the abort button.
I put two textboxes on the subform which display the primary keys of both tables. Before the record is created the first primary key shows the primary key of the mainform record I had selected, and the second textbox shows (autonumber). As soon as I start typing the second textbox shows the related child table being allocated a primary key, so far so good. However when I press the abort button, a new number appears in the second textbox, and if I hide the subform, and close the database from the now visible mainform I then find its left a blank record in the child table having the primary key value I last saw.
I have debugged to see if another command is made for a new record to be created after aborting but cannot find anything. Any ideas, thanks