closing form when previewing a report

A

Alex Martinez

Hi,

I am using Access 2002 and below is my code. In my form I have this command
button that will open up another form with a calendar control (Active X) and
when the user select the day it would open up a report in preview. My
problem is after looking at the report or printing it the form with the
calendar control comes back. What I want is to have the calendar control
form to close. How do I do this? Any tips will be appreciated. Thank you
in advance.


Private Sub CalendarWeekEnded_Click()

On Error GoTo Err_CalendarWeekEnded_Click

Dim stDocName As String

textWeekended.SetFocus
textWeekended.Value = CalendarWeekEnded.Value

stDocName = "Weekly Production Bar Graph"
DoCmd.OpenReport stDocName, acPreview

Exit_CalendarWeekEnded_Click:
Exit Sub

Err_CalendarWeekEnded_Click:
MsgBox Err.Description
Resume Exit_CalendarWeekEnded_Click

End Sub
 
F

fredg

Hi,

I am using Access 2002 and below is my code. In my form I have this command
button that will open up another form with a calendar control (Active X) and
when the user select the day it would open up a report in preview. My
problem is after looking at the report or printing it the form with the
calendar control comes back. What I want is to have the calendar control
form to close. How do I do this? Any tips will be appreciated. Thank you
in advance.

Private Sub CalendarWeekEnded_Click()

On Error GoTo Err_CalendarWeekEnded_Click

Dim stDocName As String

textWeekended.SetFocus
textWeekended.Value = CalendarWeekEnded.Value

stDocName = "Weekly Production Bar Graph"
DoCmd.OpenReport stDocName, acPreview

Exit_CalendarWeekEnded_Click:
Exit Sub

Err_CalendarWeekEnded_Click:
MsgBox Err.Description
Resume Exit_CalendarWeekEnded_Click

End Sub

Close the form when the report closes.
Code the report's Close event:
DoCmd.Close acForm, "FormName"
 
A

Andrew Backer

Well... just a thought but... can you have the report call back to the
calendar form and close it when it itself closes? Ie

Report_OnClose()
Forms("CalendarWeekEnded").CallBackFuncion
-- or close it directly ? ---
DoCmd.Close acForm, "CalendarWeekEnded", acSaveNo
End Sub

Or, if you walways want ot have it close, why not just open the report
and then, immediatly after, close the dialog with DoCmd.Close? Unless
opening the report is a modal thing (which I don't recall it being)
that shoudl work just fine?

- Andrew
 

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

Top