Re: OpenReport from form Problem



Ken,

Okay I tried to filter by openreport. See code below.

If I run it as as I get a "Type Mismatch error." If I take out the "or"
itmes and just grab the info from the single combo box I am asked to Enter
the Paramater Value which is listed just above it and the report runs as
expected.
ilIssue and cmbIssues1 are both text values.

References for DAO and Ado are both checked.

So I am stumped. Is my format not right?

Thanks for your help.

Ken Ivins



--------------------------------------------------------------------------------------------------------------
Private Sub cmdAllCountiesSelectedIssues_Click()
On Error GoTo Err_cmdAllCountiesSelectedIssues_Click

Dim stDocName As String

stDocName = "rptCountyIssuesAll-All"
DoCmd.OpenReport stDocName, acPreview, , "ilIssue = " & Me.cmbIssues1
Or Me.cmbIssues2 Or Me.cmbIssues3


Exit_cmdAllCountiesSelectedIssues_Click:
Exit Sub

Err_cmdAllCountiesSelectedIssues_Click:
MsgBox Err.Description
Resume Exit_cmdAllCountiesSelectedIssues_Click

End Sub



"Ken Snell [MVP]" <kthsneisllis9@xxxxxxxxxxxxxxxxxx> wrote in message
news:%2308DI6vNFHA.1268@xxxxxxxxxxxxxxxxxxxxxxx
> Reports do not use their "record source" queries as the source of the
> sorting order. Instead, they rely on the Sorting and Grouping settings in
> the report itself. If the only difference between all your reports is the
> sort order (the queries otherwise return exactly the same records and same
> fields), then changing the record source is not the solution that you
> need.
>
> (Note that your code is trying to use the "Filter" argument of the
> OpenReport action to change the report's RecordSource. This is not going
> to work either. The "Filter" argument allows you to designate a query that
> will filter the report's query's results. Quite honestly, none of us
> ACCESS MVPs, when we last surveyed ourselves, use this argument for
> filtering a report -- instead, we use the fourth argument,
> WhereCondition, to filter a report's recordsource. If you wanted to pass
> the recordsource string to the report, you could use the OpenArgs argument
> [in ACCESS 2002 and 2003 only] to pass it to the report, and then run code
> in the report's Open event to read that value and set the report's
> RecordSource to that string.)
>
> Post back with more information about exactly what differences you have
> for all the varied reports, and let's see if we can assist you to a
> solution.
> --
>
> Ken Snell
> <MS ACCESS MVP>
>
>
> "Ken Ivins" <ken-express@xxxxxxxxx> wrote in message
> news:uGToEouNFHA.244@xxxxxxxxxxxxxxxxxxxxxxx
>> I have run into this before and thought it was time to learn the right
>> way.
>> I have one report and many queries. The queries all have the same fields,
>> just different sorting based on the input from the user. In the past I
>> would just copy and paste the report and change its record source to the
>> new
>> query but I thought I could change the record source with code.
>>
>> On a form I created two buttons (see code below). One for one query and
>> the
>> other for the other. In both cases I got a report with the data for the
>> query in the recordsource field. If I leave the recordsource field on the
>> report blank I get no data.
>>
>> Do I need to change my code or something in the report? Access help makes
>> it
>> look easy but I am missing something.
>>
>> Thanks,
>> Ken
>>
>>
>>
>> Private Sub cmdAllCountiesAllIssues_Click()
>> On Error GoTo Err_cmdAllCountiesAllIssues_Click
>>
>> Dim stDocName As String
>> Dim stQryName As String
>>
>>
>> stDocName = "rptCountyIssues"
>> stQryName = "qryCountyByIssue-AllCountyAllIssuesRpt"
>> DoCmd.OpenReport stDocName, acPreview, stQryName
>>
>> Exit_cmdAllCountiesAllIssues_Click:
>> Exit Sub
>>
>> Err_cmdAllCountiesAllIssues_Click:
>> MsgBox Err.Description
>> Resume Exit_cmdAllCountiesAllIssues_Click
>>
>> End Sub
>>
>>
>>
>> Private Sub cmdAllCountiesSelectedIssues_Click()
>> On Error GoTo Err_cmdAllCountiesSelectedIssues_Click
>>
>> Dim stDocName As String
>> Dim stQryName As String
>>
>> stDocName = "rptCountyIssues"
>> stQryName = "qryCountyByIssue-AllCountySelectIssuesRpt"
>> DoCmd.OpenReport stDocName, acPreview, stQryName
>>
>> Exit_cmdAllCountiesSelectedIssues_Click:
>> Exit Sub
>>
>> Err_cmdAllCountiesSelectedIssues_Click:
>> MsgBox Err.Description
>> Resume Exit_cmdAllCountiesSelectedIssues_Click
>>
>> End Sub
>>
>>
>>
>
>


.