ShabanaHafiz
Programmer
I am using Microsoft Access 2003.
I created a selection criteria form. This form has two combo boxes; cboFromDate and cboToDate. Report is opened when the user clicks cmdPreviewReport. cmdPreviewReport has the following code:
I have used the code provided in faq705-2562 to Hide The Access Window. This FAQ says:
find the PopUp property for each form and set it to yes. In the OnOpen event of your startup form (if you don't have a startup form, just pick the first form you open when you open the database), put the following code:
DoCmd.RunMacro "mcrHide"
Finally, to allow reports to be previewed...in every report you will need to put:
In the OnOpen: DoCmd.RunMacro "mcrRestore"
In the OnClose: DoCmd.RunMacro "mcrHide"
So the code for open and close events are as follows:
Selection Criteria form, rpt1Select, has its PopUp property set to Yes.
When Selection Criteria form is opened and cmdPreviewReport is clicked, report appears behind the two forms; rpt1Select and Switchboard. When the report is clicked, it does not get the focus. When closeform button is clicked on rpt1Select form, still the report does not get focus upon clicking. When Exit button is clicked on Switchboard, everything closes and an error message is displayed:
The RunMacro action was canceled.
What I need is: When cmdPreviewReport is clicked, to show report above all form windows and to have focus on report.
I created a selection criteria form. This form has two combo boxes; cboFromDate and cboToDate. Report is opened when the user clicks cmdPreviewReport. cmdPreviewReport has the following code:
Code:
Private Sub cmdPreviewReport_Click()
On Error GoTo Err_cmdPreviewReport_Click
Dim stDocName As String
stDocName = "VHRunningMaint"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdPreviewReport_Click:
Exit Sub
Err_cmdPreviewReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewReport_Click
End Sub
I have used the code provided in faq705-2562 to Hide The Access Window. This FAQ says:
find the PopUp property for each form and set it to yes. In the OnOpen event of your startup form (if you don't have a startup form, just pick the first form you open when you open the database), put the following code:
DoCmd.RunMacro "mcrHide"
Finally, to allow reports to be previewed...in every report you will need to put:
In the OnOpen: DoCmd.RunMacro "mcrRestore"
In the OnClose: DoCmd.RunMacro "mcrHide"
So the code for open and close events are as follows:
Code:
Private Sub Report_Close()
DoCmd.RunMacro "mcrHide"
End Sub
Private Sub Report_Open(Cancel As Integer)
DoCmd.RunMacro "mcrRestore"
End Sub
Selection Criteria form, rpt1Select, has its PopUp property set to Yes.
When Selection Criteria form is opened and cmdPreviewReport is clicked, report appears behind the two forms; rpt1Select and Switchboard. When the report is clicked, it does not get the focus. When closeform button is clicked on rpt1Select form, still the report does not get focus upon clicking. When Exit button is clicked on Switchboard, everything closes and an error message is displayed:
The RunMacro action was canceled.
What I need is: When cmdPreviewReport is clicked, to show report above all form windows and to have focus on report.