I've noticed in the past that if I have a button control on a form and have an code like such behind it:
If I double click, or just click fast enough I can fire off that event before the form closes, thereby running the query twice. Is it a better practice to structure my code as such:
The form control I am using is saving sale records and then resetting the form so it is not identical to the above, but similar enough for it to get the point across.
Code:
Private Sub BtnSaveClose_Click()
currentdb.execute "INSERT INTO tblTable.* FROM tblTable.*;"
DoCmd.Close frmForm
end sub
If I double click, or just click fast enough I can fire off that event before the form closes, thereby running the query twice. Is it a better practice to structure my code as such:
Code:
Private Sub BtnSaveClose_Click()
DoCmd.Close frmForm
currentdb.execute "INSERT INTO tblTable.* FROM tblTable.*;"
end sub
The form control I am using is saving sale records and then resetting the form so it is not identical to the above, but similar enough for it to get the point across.