Re: OpenReport from form Problem



Dear Ken,

Thanks for your response. I need to look over you thoughts closer. Hopefully
tomorrow. I'll then lay out what I am trying to do and how I thought I could
select the query. Actually filtering with code would actually be better. I
tried that and ran into other problems. I'll outline my errors as well.
Please do not give up on me but check after the weekend for more details.

Thanks,
Ken



"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
>>
>>
>>
>
>


.


Loading