VBA Report Module Auto populate "save as" name (1 Viewer)

alekkz

Registered User.
Local time
Today, 14:07
Joined
Oct 14, 2016
Messages
27
Gasman and Buddha

Thanks for your help... I will look into those videos...
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:07
Joined
Sep 21, 2011
Messages
10,603
Come back when you have a little more foundation to work with. Those videos are going to save you a whole lot of grief in the future. :)

I also still Google the syntax for commands like that. Once you know the command then Intellisense can kick in.
Also make sure you always have Option Explicit at the top of your rmodules. best to set in VBE window/Tools/Oprions/Require Variable Declaration.
 

Isaac

Lifelong Learner
Local time
Today, 14:07
Joined
Mar 14, 2017
Messages
6,573
I would recommend commenting out the "on error" line completely. The breakpoints are a fine idea but you won't even need those if you comment out the "on error goto" line completely. Then the code will go into debug mode directly on the line where the error is. Once that happens, click Debug. Then view the Immediate window (View, Immediate window), and you can start practicing some of the debugging techniques (such as asking the immediate window a question, such as ?varname.value (and hit Enter) ........ FWIW
 

Isaac

Lifelong Learner
Local time
Today, 14:07
Joined
Mar 14, 2017
Messages
6,573
wouldn't this line:
strRptName = Forms![Specific_Information_frm]![WBS Number] & " " & "Ultrasonic Report"
...be returning only a potential file name? or does it contain a folder path too? Seems like it probably does not contain a folder path.... but again, ask the immediate window that question while debugging.
 

Cronk

Registered User.
Local time
Tomorrow, 07:07
Joined
Jul 4, 2013
Messages
2,669
Seems to me that the OP is wanting to have a different PDF document for different items.

Using the docmd.outputTo does not provide for any filtering on the record source for the report. When I have this type of requirement, I base the report on a query and modify the SQL of an existing query to filter the data required. Alternatively, the report could be based on a temporary table which is populated with the required record(s).
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:07
Joined
Sep 21, 2011
Messages
10,603
Gasman and Buddha

Thanks for your help... I will look into those videos...
You could take what you might think is a step backwards.
Hard code the report and output filename to at least get it working correctly. Only then start replacing hard coded values with variables.

I believe you are confusing the report name and output filename. The report should really be the same report just with different criteria for it's source.
The filename would likely be a different name taking into account the WBSNumber.?
As mentioned the source for the report is hopefully taken into account with the WBSNumber on the form, perhaps by having that control as criteria in the query.?
 

HalloweenWeed

Member
Local time
Today, 17:07
Joined
Apr 8, 2020
Messages
147
I would recommend commenting out the "on error" line completely. The breakpoints are a fine idea but you won't even need those if you comment out the "on error goto" line completely. Then the code will go into debug mode directly on the line where the error is. Once that happens, click Debug. Then view the Immediate window (View, Immediate window), and you can start practicing some of the debugging techniques (such as asking the immediate window a question, such as ?varname.value (and hit Enter) ........ FWIW
Yes, this is SOP to debug code.
 

Users who are viewing this thread

Top Bottom