Unable to undo a record entered in the bound form

M

midnite oil

Hi,

My form has a bunch a textboxes and combos and a subform with just a 1
field. There are 3 required fields in the main form and the 1 field in the
subform. All controls are bound to tables.

Testing Case 1 :
if none of the required fields have been entered, user click CLOSE [X]
button, the usual inelegant Access message pops up and I also have a
form-Unload event that displays to the user to click on the app. Return
TO..button to exit, the option to return to the form to enter rest of
required fields or forget it - return to main menu. If the user selects
return to main menu, the following is executed and the data will not be
created.

Testing Case 2 :
if all 3 required fields have been entered except the one in the
subform, user click CLOSE [X] button, ... as above.....since the subform is
a required field also. The following is executed but the ME.UNDO does not
undo the record being entered. It gets created !!!

'if mandatory data not entered, prompt user
'edit a record - all mandatory fields are to be filled before
leaving form
If boolEdit = True Then
MsgBox strSomeEmptyData, vbOKOnly + vbInformation
Exit Sub
Else
'new record - option to undo entry or fill up mandatory
fields before leaving form
If MsgBox(strSomeEmptyData, vbYesNo + vbQuestion) = vbYes
Then
'do nothing
Exit Sub
Else
Me.Undo
boolClickCloseWindow = True
DoCmd.Close acForm, Me.Name, acSaveNo
Exit Sub
End If
End If

Does anybody know how can I prevent this record from being created in the
table ??? Thank you in advance.
 
M

midnite oil

found my answer .... DoCmd.RunCommand acCmdUndo

Me.Undo works only before data is updated to the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top