Report based on Paramaterized query (1 Viewer)

gem1204

Registered User.
Local time
Today, 10:17
Joined
Oct 22, 2004
Messages
54
I need to open a report that is based on a parameterized query. The report can be opened from a variety of forms that users have to access to open the report. I know how to use the do command to open the report and pass a filter argument but that doesn’t work if the report is based on parameters. I don’t want to change the source of the parameters to a control on the form because this report can be accessed from several different forms and the query itself is used in several different reports showing different amounts of detail.

I’ve always been taught that it’s better to open a report with the data you want to see rather than opening a report and then applying a filter after it is opened. Even if I wanted to, I’m not allowed to change the report or the query so I’m stuck with the parameterized query and making it work. The query is fairly complex with several tables one of which has over 200,000 rows.
he source of the parameters to a control on the form because this report can be accessed from several different forms and the query itself is used in several different reports showing different amounts of detail.

I can use this code to open a form based on the parameterized query but when I tried to use it on a report I got a message “This feature is only available in and ADP” and my tables are based on ODBC tables from a pervasive database and not an sql server ADP.
uery and making it work. The query is fairly complex with several tables one of which has over 200,000 rows.
he source of the parameters to a control on the form because this report can be accessed from several different forms and the query itself is used in several different reports showing different amounts of detail.

This is my code I can use to open a form
Code:
Private Sub Form_Open(Cancel As Integer)
    'This doesn't work on a report
    Dim mydb As dao.Database
    Dim Myqdf As dao.QueryDef
    Set mydb = CodeDb
    Set Myqdf = mydb.QueryDefs("qryPODetails")
    Myqdf.Parameters("WhatPO").Value = "0008009"
    Set Me.Recordset = Myqdf.OpenRecordset
End Sub

Is there any way to open this report as it is without removing the parameters and using a filter argument instead?

I'm using MS Access 2010
 

JHB

Have been here a while
Local time
Today, 19:17
Joined
Jun 17, 2012
Messages
7,732
Hmm - I don't know if it helps, but try to change the "Set mydb = CodeDb" to "Set mydb = CurrentDb"
 

Users who are viewing this thread

Top Bottom