View Full Version : Creating two reports from one form.


DanMonkey
04-25-2004, 05:38 AM
Hello there,

I have a filter form which I have no problem with coding the filter for the reports. But I can not link the filter form to the reports.

It is setup up so the filter form is opened first then the user sets the filter (checkboxes, combo boxes etc) and one of two buttons are pressed as required to create the different reports.

But I keep one getting an error saying that the name of the report I am trying to link to is mispelt of does or is not open. Please help. See my code below:

Filter form code:

Option Compare Database

'COMMENT: declaring Variables for reports
Dim m_rptSales As Report
Dim m_rptProducts As Report

//FIRST BUTTON//
Private Sub btnBUTTON1_Click()

// For Some reason instead of opening the report it starts to print !!//
DoCmd.OpenReport "rptProducts"

//This is the line that is highlight when error is thrown//
Set m_rptProducts = Reports("rptProductReport")

//This is where all of my filter requirements go //

MsgBox (strFilter)
With m_rptProducts
'COMMENT: setting the filter for the report
.Filter = strFilter
.FilterOn = True
End With

End Sub


Private Sub btnBUTTON2_Click()

// For Some reason instead of opening the report it starts to print !!//
DoCmd.OpenReport "rptSalesReport"

//This is the line that is highlight when error is thrown//
Set m_rptSales = Reports("rptSalesReport")

//This is where all of my filter requirements go //

With m_rptSales
'COMMENT: setting the filter for the report
.Filter = strFilter
.FilterOn = True
End With

End Sub

What am I doing wrong??

DBL
04-25-2004, 06:28 AM
I can help with a bit of this. Printing the report is the default set up, if you want to preview the report you need to specify this in the code:

DoCmd.OpenReport "rptProducts", acViewPreview

HTH a little

DBL

DanMonkey
04-25-2004, 08:08 AM
Thank for that DBL, that is abit of the problem sorted.

DanMonkey
04-25-2004, 08:13 AM
Hey that sorted out the whole problem!!!!!


Thanks alot DBL your a star :)

DBL
04-25-2004, 08:16 AM
Hey that sorted out the whole problem!!!!!


Thanks alot DBL your a star :)

sheer fluke!