use record as part of filename

Status
Not open for further replies.

KeythStone

New Member
Joined
Mar 30, 2011
Messages
36
Hello,

Trying to use a record from "ReportList" as part of the filename where I'd publish a report named the same as the record. So say the record was "ReportName"

I'd want something like:

Function test()
On Error GoTo test_Err
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim StrClient As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("ReportList", dbOpenDynaset)
rst.MoveFirst
Do While Not rst.EOF
With rst
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)", StrClient, False, "", 0, acExportQualityPrint
DoCmd.Close acReport, "AIM (Assignment,DB): ALL OPEN (AIM by DB: ALL OPEN)"
.MoveNext
End With
Loop
rst.Close

test_Exit:
Exit Function


Any thoughts if this will work. I'm still trying different things. All help is appreciated,

Stay Smooth,
KeythStone
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
See: http://www.mrexcel.com/forum/showthread.php?t=565759

Keyth,
Please continue in the original thread. Per forum rules, all follow-ups, clarifications, and bumps should be posted back to the original thread. All threads of a duplicate nature are typically locked or deleted (rule #9 here: http://www.mrexcel.com/forum/showthread.php?t=99490).

Have you looked at the link I provided in that thread? It shows you how to loop through your recordset and capture a field value (can set equal to a variable instead of returning to a Message Box). If you have directly related follow-up questions, post them to your original thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

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