Using record in table for parameter

KeythStone

New Member
Joined
Mar 30, 2011
Messages
36
Hey all,

I would like to know if I could use a recordset in a table to fill in a parameter for a query. If so I would like to use Do Until .EOF. MoveNext.

I would also like to be able to use the recordset for part of a filename, 'ReportName'


Function test()
On Error GoTo test_Err
Set db = CurrentDb()
Set ReportName = db.OpenRecordset("ReportList", dbOpenDynaset)
Do Until ReportName.EOF
Dim StrClient As String

StrClient = "F:\OP_CS\Client Reporting\ReportName\AIM\" & Format(Date, "yyyymmdd") & ".pdf"

DoCmd.OpenReport "AIM (Assignment,DB): ALL OPEN (AIM by DB: ALL OPEN)", acViewPreview, "", "", acNormal

DoCmd.OutputTo acOutputReport, "AIM (Assignment,DB): ALL OPEN (AIM by DB: ALL OPEN)", "PDFFormat(*.pdf)", StrDocClient, False, "", 0, acExportQualityPrint

DoCmd.Close acReport, "AIM (Assignment,DB): ALL OPEN (AIM by DB: ALL OPEN)"


Any help is much appreciated.
Stay Smooth,
KeythStone
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I would like to know if I could use a recordset in a table to fill in a parameter for a query
Why not just include that table in your query?

If it is just a one-record table, then you don't even need to link it to any of the other objects in your query.
Then you can use any of the fields you want in the query (in calculations or criteria).
 
Upvote 0
Thanks for your response.

So more specifically. It's not just one record being pulled but many. And the query would be using one at a time. For e.g. Query1.AssignedTo = "IPC." That query makes a report with the data and then I publish the report on a shared drive. Next, the same process but using the second record, "STG." And on till the end of the list.

I'm thinking loop statements. But my first concern is being able to pull from the table for each record. Then, I'd like to pull from the same table for a segment of a filename where i'd be publishing the report. (see filename segment above in blue).

Is this possible? Thanks,
KeythStone
 
Upvote 0

Forum statistics

Threads
1,224,526
Messages
6,179,322
Members
452,906
Latest member
Belthazar

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