Closing a Form

Sunnylei

Registered User.
Local time
Today, 02:10
Joined
Mar 5, 2011
Messages
87
Hi
How to close a Form without a close button?

Sunny :confused:
 
Just say "Abracadabra!!!" ;)

Your question isn't clear enough. What are you trying to do? What do you mean by closing a form without a button. Can a door be closed without (something) pushing it?

Explain more and we might be able to help.
 
Hi,
I create a form as a filter. I'm trying to filter out same job codes in a form and print out the codes report by using this form. I enter codes range, and click 'ok' button. I can see report preview page. However, I need click close button to close the form. How can I let the form automatically close when preview page appear without click close button?

Thanks

Sunny :confused:
 
DoCmd.Close "NameOfFormhere"

will close the form. So you put it just below the line where it reads

DoCmd.OpenReport "ReportName"
 
Sorry, should I paste the codes on the form's on close property?

Thanks

Sunny:confused:
 
in VBA code of the Report Print Button, just write this code after the report Preview code:

docmd.close accForm ("FormName_tobeClosed")
 
DoCmd.Close "NameOfFormhere"

will close the form. So you put it just below the line where it reads

DoCmd.OpenReport "ReportName"
.

Sorry, it still nedds to click 'close' button. I just want to see it is automatically closed when report preview page appears after click 'ok'
 
what the code you are using to print the report? can you post the OK button code here? and also the form name you want to close.
 
in VBA code of the Report Print Button, just write this code after the report Preview code:

Which version VBA are you using. My version 2007 cann't recognise the code: docmd.close accForm ("FormName_tobeClosed")

Sunny
 
what the code you are using to print the report? can you post the OK button code here? and also the form name you want to close.

I created a form as a filter. I'm trying to filter out same job codes, and print it out by using the form. I enter job codes range and click 'ok' button. I can see the same job codes report preview, however, I have to click close button to close the form. How can I let the form automatically closes when preview page appears on screen without click close button?

Thanks

Sunny
 
Just say "Abracadabra!!!" ;)

Your question isn't clear enough. What are you trying to do? What do you mean by closing a form without a button. Can a door be closed without (something) pushing it?

Explain more and we might be able to help.

I created a form as a filter. I'm trying to filter same job codes and print out its report by using the form. I entered job code range, and click 'ok' button. I can see same job codes preview report, however, I have to click 'ok' button to close the form. How can I let the form automatically closes when preview report appears on the screen without click close button?:confused:
Thanks

Sunny
 
Which version VBA are you using. My version 2007 cann't recognise the code: docmd.close accForm ("FormName_tobeClosed")

Sunny

this is common for all the versions, you have to change the form name to your formName which you want to close.

docmd.close accForm ("YourFormName_tobeClosed")

you did not post the code of printing the report... you can go to the code by right clicking on the button then in the event property of the button click just click on the (...) ellipsis to read the code.
 
this is common for all the versions, you have to change the form name to your formName which you want to close.

docmd.close accForm ("YourFormName_tobeClosed")

you did not post the code of printing the report... you can go to the code by right clicking on the button then in the event property of the button click just click on the (...) ellipsis to read the code.

Sorry, my version cannot recognises 'accForm'

Thanks

Sunny
 
Looks like I missed the syntax. Here's the correct syntax:

DoCmd.Close acForm, "NameOfForm"

Replace the bit in blue. Then put the code in the Load event of the report. Click the elipsis button -> select Code Builder -> paste amended code in there.
 
Looks like I missed the syntax. Here's the correct syntax:

DoCmd.Close acForm, "NameOfForm"

Replace the bit in blue. Then put the code in the Load event of the report. Click the elipsis button -> select Code Builder -> paste amended code in there.

Thank you very much! It works for me!!!:)
 

Users who are viewing this thread

Back
Top Bottom