closing a pop up

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Helo, I have a button on a form that brings up a pop up that has buttons to
bring up reports. My question is what can I add to the VBA code to close this
pop up when I run a button? all my reports run a query that asks for a date
range name ect. so I still want to be able to run that. The pop up will stay
ontop everything untill I close it and its getting anoying...
Here is one of the codes for one of the buttons on my pop up.

Private Sub Command86_Click()
On Error GoTo Err_Command86_Click

Dim stDocName As String

stDocName = "Individual Stats"
DoCmd.OpenReport stDocName, acPreview

Exit_Command86_Click:
Exit Sub

Err_Command86_Click:
MsgBox Err.Description
Resume Exit_Command86_Click
 
You can close the form

DoCmd.Close acForm, Me.Name

If the form needs to remain open while the report is open then set the
form's visible property to false instead of closing it. Then in the
report's close event add code to close the form (or make it visible)

DoCmd.Close acForm, "Name of form as a string"



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
John, Where would I add the code? I want the form to close when I click on a
button on the form to run the query for the report. Thanks!
 
I dont quit understand? I will explain how I have things set up and mabe you
can tell me what im doing wrong. I have a form named frmMaindB which has a
button that brings up another form named frm_ReportsSwitchboard (Which is a
pop up) and it has several buttons on it. each button runs a query that gives
me a report. Most of my querys ask for a date range and employees name. Where
and on what form or query would I add something to close the
frm_ReportsSwitchboard form when I press one of the buttons on that form (pop
up)? I hope this helps..... Thanks!
 
If I understand correctly, you've got one or more buttons on
frm_ReportsSwitchboard which launch the queries.

Presumably that means you've got code like:

Private Sub MyCommandButton_Click()

DoCmd.OpenQuery "NameOfQuery"

End Sub

You need to add

DoCmd.Close

after the DoCmd.OpenQuery line.
 
I tried to add the DoCmd.Close after the open and the report never opened.
Here is the code of one of the buttons. I tried sticking it everywher in
here...Thanks!

Private Sub Individual_Employee_Percent_Click()
On Error GoTo Err_Individual_Employee_Percent_Click

Dim stDocName As String

stDocName = "Employee Delay Percent"
DoCmd.OpenReport stDocName, acPreview

Exit_Individual_Employee_Percent_Click:
Exit Sub

Err_Individual_Employee_Percent_Click:
MsgBox Err.Description
Resume Exit_Individual_Employee_Percent_Click
End Sub
 
Ok I got it to work. I just made a macro to close the frm_ReportsSwitchboard
and added it to all my reports on open event. Works great! Thanks for the
help.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top