Reputation: 18228
I have a form that has some buttons, and when user click on a button, the form should be closed (unloaded). I used the following methods, but all generate error:
docmd.close me
unload me
What is the best way to close or unload a form in VBA (from code inside the form)
Upvotes: 6
Views: 35893
Reputation: 97131
DoCmd.Close
expects ObjectType as its first argument, followed by ObjectName which is a variant string as the object name.
So in the click event of a command button which is intended to close the current form, I use this ...
DoCmd.Close acForm, Me.Name
Upvotes: 11