M
midnite oil
Hi,
Thought I had the solution earlier this afternoon using DoCmd.RunCommand
acCmdUndo.
Main form has 2 required fields. Subform has 1 required field. All fields
are bound to tables. I have a form_Unload function to trap if user click
[X] to exit form, if yes, message is displayed to inform user to click the
Return Main Menu button to exit instead. If its a new record,
ValidateAllRequired function will validate all required fields entered, if
not, give the user the option to abort or or continue with the entry.
Test Case 1 : On the Main form I entered both required fields, click [X] to
close form. My form_Unload event gets executed and inform me to click
Return Main Menu to exit which I did and I get the message that Subform
required field is missing - do I want to continue or exit - I choose the
exit option. DoCmd.RunCommand acCmdUndo gets executed and removed the
record that has been created in the Main form and all is good.
Test Case 2 : On the Main form I entered both required fields as well as
required field in subform. Remove the required field entry in the subform.
Click [X], message informs me to click Return Main Menu to exit, click
Continue data entry. Enter the required field in subform. Remove one of
the required fields in Main form. Click Return Main Menu button, receives
message that Main form required field is not entered, abort or continue the
data entry. I selected ABORT - DoCmd.RunCommand acCmdUndo gets executed
but it did not Undo the main form record.
I am lost now. I have to control the form such that the parent must only
exist with a child record. Can someone please, please help me with this !
Thought I had the solution earlier this afternoon using DoCmd.RunCommand
acCmdUndo.
Main form has 2 required fields. Subform has 1 required field. All fields
are bound to tables. I have a form_Unload function to trap if user click
[X] to exit form, if yes, message is displayed to inform user to click the
Return Main Menu button to exit instead. If its a new record,
ValidateAllRequired function will validate all required fields entered, if
not, give the user the option to abort or or continue with the entry.
Test Case 1 : On the Main form I entered both required fields, click [X] to
close form. My form_Unload event gets executed and inform me to click
Return Main Menu to exit which I did and I get the message that Subform
required field is missing - do I want to continue or exit - I choose the
exit option. DoCmd.RunCommand acCmdUndo gets executed and removed the
record that has been created in the Main form and all is good.
Test Case 2 : On the Main form I entered both required fields as well as
required field in subform. Remove the required field entry in the subform.
Click [X], message informs me to click Return Main Menu to exit, click
Continue data entry. Enter the required field in subform. Remove one of
the required fields in Main form. Click Return Main Menu button, receives
message that Main form required field is not entered, abort or continue the
data entry. I selected ABORT - DoCmd.RunCommand acCmdUndo gets executed
but it did not Undo the main form record.
I am lost now. I have to control the form such that the parent must only
exist with a child record. Can someone please, please help me with this !