I've used the following code behind a button to close a form and it worked great. I made changes to the design and made the form a subform and the code is not working. Please suggest how to close the main form from a button on the subform.
On Error GoTo HandleError
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close ObjectType:=acForm, ObjectName:=Me.Name, Save:=acSavePrompt
HandleExit:
Exit Sub
HandleError:
MsgBox Err.Description
Resume HandleExit
On Error GoTo HandleError
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close ObjectType:=acForm, ObjectName:=Me.Name, Save:=acSavePrompt
HandleExit:
Exit Sub
HandleError:
MsgBox Err.Description
Resume HandleExit