Change Report RecordSource and Open with vba

J

John Dhong

Hello, I have a Report r1 that relies on a Query q1.
That query requires a parameter when it's executed (myParam).
Usually, user will automatically be prompted with an InputBox to
assign it.

Now, I know I can set myParam in my query by using the code at the end
of this message.

But how can I use the query, with the already defined parameter, to
run my report? (I want to use my currently closed, existing report,
then assign it the new RecordSource and finally display it on the
screen.)


Dim dbs
Set dbs = CurrentDb

'New table
Dim tableName As String
tableName = "table1"

Dim qdf

Set qdf = dbs.QueryDefs("UnfilledDates")
qdf.Parameters("myParam") = cboEmployee.Value

Set rs = qdf.OpenRecordset


Thank you in advance for your help!
 
Top