Re: Opening report from a form field as parameter



On Thu, 16 Jun 2005 13:35:59 -0400, Alain wrote:

> 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.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.



Relevant Pages

  • Re: Running 2 reports in a form together
    ... Form where the report is run from is called "clientanddate" ... Dim strReport As String 'Name of report to open. ... here is an example that tests criteria and builds a filter string to use as a parameter in OpenReport ...
    (microsoft.public.access.forms)
  • Re: Running 2 reports in a form together
    ... Form where the report is run from is called "clientanddate" ... Dim strReport As String 'Name of report to open. ... What I need it to do is also filter in the date report using the clients name ... here is an example that tests criteria and builds a filter string to use ...
    (microsoft.public.access.forms)
  • Re: Sending report about the current record in mail
    ... You can save the record by setting Dirty to False. ... >> filter so the report opens and is sent with just the record you need. ... Private Sub Report_Open ...
    (microsoft.public.access.forms)
  • Re: Can I add a list box to the option group?
    ... It is a better plan to build the filter string in code then launch the report using the WHERE condition argument to OpenReport -- then end result is the same: ... the advantage of building it in code is that you can ignore criteria that is not filled and you don't end up with a long equation in the report filter property. ... dim mFilter as variant ...
    (microsoft.public.access.forms)
  • Re: Search Filter for Report
    ... Private Sub cmdCreateReport_Click ... Allen Browne - Microsoft MVP. ... Limiting a Report to a Date Range ... That example applies the filter string to a form, ...
    (microsoft.public.access.formscoding)