Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Want form to open when report is triggered 1

Status
Not open for further replies.

NeilT123

Technical User
Jan 6, 2005
302
GB
Hi All, I am not sure whether to post in the forms or reports section so have opted for reports.

I have lost patience with this so any help would be appreciated.
I have a database that I have developed over a few years and if I was starting from fresh then there are lots of things I would do differently but at the moment I have to make do with what I have.
I use the excellent Lebans PDF codes and have tweaked a lot of the settings to automate report names etc.
I have a form which I call frmPrintRpts and this form lists all of my reports. I use option buttons to select the report and then a command button to trigger the print or PDF or preview.
Code would be something like
Code:
Private Sub CmdPreviewReport_Click()
    On Error Resume Next
DoCmd.OpenReport Me.[ReportName], acViewPreview
DoCmd.Close acForm, "frmPrintRpts"
If Err = 2501 Then Err.Clear
End Sub
I have created a new report which I can filter and the filters are on a form so what I want to be able to do is trigger the report from the button above, the filter form opens and I make my selections, the filter form close and the report opens showing the filtered data.
I have tried opening the filter form via the on load of the report but just get into a mess. And to be honest am now so confused I don’t know which way to turn.
Does anyone have any suggestions as to how I might achieve what I am trying to do or is it just not possible?
Thanks as always for any help or suggestions
Neil
 
I typically add "the filters are on a form" to the original frmPrintReports so there aren't two forms required. If that doesn't work, I would
Code:
Private Sub CmdPreviewReport_Click()
    On Error Resume Next
    Select Case Me.ReportName
        Case "new report name"
            DoCmd.OpenForm "form with filters"
        Case Else
            DoCmd.OpenReport Me.[ReportName], acViewPreview
    End Select
    DoCmd.Close acForm, "frmPrintRpts"
    If Err = 2501 Then Err.Clear
End Sub
Add a button on the "form with filters" to open the report.

Duane
Hook'D on Access
MS Access MVP
 
Thank you Duane. I had been trying to use an if statement, without success.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top