Subject: form that opens reports and closes form
Posted By: hartliec Post Date: 12/12/2006 4:33:12 PM

I need help with a simple Access 2000 form that opens several reports. I would like the menu to always stay in the background and the reports to display maximized in the front of the menu. And as the reports are closed the menu will be visible.

Here is the code I have that opens the reports and closes the menu.


Private Sub Preview_Click()
On Error GoTo Err_Preview_Click


    
    If (Forms![Menu]!selectCategory) = "View All Discharged Clients" Then
         DoCmd.OpenReport "RptDischarged", acViewPreview
         DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
          
    If (Forms![Menu]!selectCategory) = "View All Currently Enrolled Clients" Then
         DoCmd.OpenReport "RptEnrolled", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
        If (Forms![Menu]!selectCategory) = "View All FA Discharged Clients" Then
         DoCmd.OpenReport "RptFAdischarged", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
    
        If (Forms![Menu]!selectCategory) = "View All Follow Along Clients" Then
         DoCmd.OpenReport "RptFollowAlong", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
            If (Forms![Menu]!selectCategory) = "View All Intake Clients" Then
         DoCmd.OpenReport "RptIntake", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
    
        If (Forms![Menu]!selectCategory) = "View All Nonadmitted Clients" Then
         DoCmd.OpenReport "RptNotAdmitted", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
    If (Forms![Menu]!selectCategory) = "Search IFSP Dts to Build a Custom Rpt" Then
        DoCmd.OpenQuery "QRYPIVOT", acViewPivotTable, acReadOnly
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
    
    If (Forms![Menu]!selectCategory) = "Search Database by Ref Date Range" Then
         DoCmd.OpenReport "RptRefDate", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If

    If (Forms![Menu]!selectCategory) = "Search Database by Date of Birth Range" Then
         DoCmd.OpenReport "RptDOB", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    

    
        If (Forms![Menu]!selectCategory) = "Search by Disposition Date Range" Then
         DoCmd.OpenReport "RptDisposDte", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
        If (Forms![Menu]!selectCategory) = "Search by Last Contact Date Range" Then
         DoCmd.OpenReport "RptIntContactDate", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
        If (Forms![Menu]!selectCategory) = "All Client Mailing Labels" Then
         DoCmd.OpenReport "All Client Mailing Labels", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    
        If (Forms![Menu]!selectCategory) = "Active Client Mailing Labels" Then
         DoCmd.OpenReport "Active Client Mailing Labels", acViewPreview
        DoCmd.Maximize
        DoCmd.RunCommand acCmdFitToWindow
    End If
    

    DoCmd.Close acForm, Me.Name
Exit_Preview_Click:
    Exit Sub

Err_Preview_Click:
    MsgBox Err.Description
    Resume Exit_Preview_Click
End Sub




NewWM
Reply By: mmcdonal Reply Date: 12/13/2006 8:00:11 AM
As a general rule, the reports should have their pop up property set to Yes so they appear in front of the active form - which I am assuming is also maximized.

The report On Open event is where you want the DoCmd.Maximize code, not on the button On Click event.

When they open the report, do not close the form, and it will be there when they close the reports.

HTH

mmcdonal

Go to topic 53571

Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87
Return to index page 86