By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,404 Members | 2,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,404 IT Pros & Developers. It's quick & easy.

Code to make form unload itself

P: 69
Hello, All.

I'm embarrassed to even ask this question because it seems like such a simple thing. But, here it is …

What is the code to make a form unload itself?

I have a form with a number of controls and buttons on it. When the user clicks the button ‘A’, I want the form to close itself. I’ve tried using the “Unload” statement, but Access 2002 doesn’t like it. I get a #361 run-time error.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button_A_Click()
  2. Unload Me
  3. Exit Sub
Can anyone toss me a bone on this one? I’m sick of spinning my wheels on this.

Humbly,
Scott
May 16 '07 #1
Share this Question
Share on Google+
3 Replies


Denburt
Expert 100+
P: 1,356
You can close the form using the following method.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button_A_Click()
  2. DoCmd.Close
  3. exit sub
If you have code that you would like to run in the unload event then you can call the unload event using the following:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Button_A_Click() 
  2. Form_Unload False
  3. exit sub
May 16 '07 #2

P: 69
Ugh! I knew it was going to be something simple!

Thanks for helping!

Scott
May 16 '07 #3

Denburt
Expert 100+
P: 1,356
It's my pleasure! :)
May 16 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.