Opening report from a form field as parameter

A

Alain

Hi ,

I would like to know on how to fix this problem when I open a report with a
criteria as a filter,
"The Action or Method requires a ReportName Argument" is showing at the
docmd.openreport

Here is the code I use on my form
Private Sub btnGenerateReport_Click()
If cboDivision.Value <> "" Then
DataExchange.SetHeading cboDivision.Value
DoCmd.OpenReport rptRentRoll, acViewPreview
DoCmd.Maximize
Else
MsgBox "Veuillez sélectionner une bannière de la liste déroulante."
End If
End Sub
and here is the code I use on my report
Me.FilterOn = True
Me.Filter = "Division like '" & Forms!ReportGenerator!cboDivision.Value
& "*'"

TIA

Alain
 
D

Duane Hookom

Consider changing your code to:

Private Sub btnGenerateReport_Click()
Dim strWhere as String
If cboDivision.Value <> "" Then
DataExchange.SetHeading cboDivision.Value
strWhere = "[Division] like '" & Me.cboDivision & "*'"
DoCmd.OpenReport rptRentRoll, acViewPreview, , strWhere
DoCmd.Maximize
Else
MsgBox "Veuillez sélectionner une bannière de la liste déroulante."
End If
End Sub
 
A

Alain

Thanks Duane,
just tried it and it still give me the same error
The Action or Method requires a ReportName Argument
at the docmd.openreport line

Alain

Duane Hookom said:
Consider changing your code to:

Private Sub btnGenerateReport_Click()
Dim strWhere as String
If cboDivision.Value <> "" Then
DataExchange.SetHeading cboDivision.Value
strWhere = "[Division] like '" & Me.cboDivision & "*'"
DoCmd.OpenReport rptRentRoll, acViewPreview, , strWhere
DoCmd.Maximize
Else
MsgBox "Veuillez sélectionner une bannière de la liste déroulante."
End If
End Sub

--
Duane Hookom
MS Access MVP


Alain said:
Hi ,

I would like to know on how to fix this problem when I open a report with
a criteria as a filter,
"The Action or Method requires a ReportName Argument" is showing at the
docmd.openreport

Here is the code I use on my form
Private Sub btnGenerateReport_Click()
If cboDivision.Value <> "" Then
DataExchange.SetHeading cboDivision.Value
DoCmd.OpenReport rptRentRoll, acViewPreview
DoCmd.Maximize
Else
MsgBox "Veuillez sélectionner une bannière de la liste
déroulante."
End If
End Sub
and here is the code I use on my report
Me.FilterOn = True
Me.Filter = "Division like '" &
Forms!ReportGenerator!cboDivision.Value & "*'"

TIA

Alain
 
F

fredg

Hi ,

I would like to know on how to fix this problem when I open a report with a
criteria as a filter,
"The Action or Method requires a ReportName Argument" is showing at the
docmd.openreport

Here is the code I use on my form
Private Sub btnGenerateReport_Click()
If cboDivision.Value <> "" Then
DataExchange.SetHeading cboDivision.Value
DoCmd.OpenReport rptRentRoll, acViewPreview
DoCmd.Maximize
Else
MsgBox "Veuillez sélectionner une bannière de la liste déroulante."
End If
End Sub
and here is the code I use on my report
Me.FilterOn = True
Me.Filter = "Division like '" & Forms!ReportGenerator!cboDivision.Value
& "*'"

TIA

Alain

The name of the report must be enclosed within quotes:
DoCmd.OpenReport "rptRentRoll", acViewPreview

I would also use the OpenReport's Where argument to filter the
records, instead of setting the Report's Filter.

If the Combo box bound column is Text (as indicated):

DoCmd.OpenReport "rptRentRoll", acViewPreview, , "Division like '" &
Me!cboDivision & "*'"

No need to explicitly use the Value property as Value is the default.
 
A

Alain

Thanks Fred,
works good

Alain

fredg said:
The name of the report must be enclosed within quotes:
DoCmd.OpenReport "rptRentRoll", acViewPreview

I would also use the OpenReport's Where argument to filter the
records, instead of setting the Report's Filter.

If the Combo box bound column is Text (as indicated):

DoCmd.OpenReport "rptRentRoll", acViewPreview, , "Division like '" &
Me!cboDivision & "*'"

No need to explicitly use the Value property as Value is the default.
 

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