Parameter passing to a query in a modual

fliper

New Member
Joined
Mar 16, 2004
Messages
3
Hello,
I was wondering how do you open a recordset on a query if this query needs a criteria??? I want to open it in a moduel that is. And i need to pass a parrameter. But how???

Thanks
Fliper
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Here is a snippet of code from one of my modules which should point you in the right direction.

Code:
Private Sub ColourParetoGraph()
Dim dbs As Database
Dim qdf As QueryDef
Dim prm As Parameter
Dim rstGraphData As Recordset

    ' Return reference to current database.
    Set dbs = CurrentDb
    ' Open dynaset-type Recordset object.
    Set qdf = dbs.QueryDefs("qryGraphReasonsComparisons")
    For Each prm In qdf.Parameters
        prm.Value = Eval(prm.Name)
    Next prm
    
    Set rstGraphData = qdf.OpenRecordset()

................

peter

Edited to add code! :oops:
 
Upvote 0

Forum statistics

Threads
1,221,645
Messages
6,161,040
Members
451,682
Latest member
ogoreo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top