Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Name Argument Error

Status
Not open for further replies.

Ub2010

MIS
Nov 30, 2010
4
US
Hello,
I am getting the following error when I try to run a report - "The Action or method requires a Report Name Argument".

Background - I basically have a form with different boxes and based on what the vendor name is (List14 in the code below), it should run a particular report.

Code -


Dim stDocName As String
Dim stLinkCriteria As String

stDocPS = "RPT_EC_ENGAGEMENTS"
stDocCC = "RPT_CC_ENGAGEMENTS"
stDocIE = "RPT_IE_ENGAGEMENTS"
stDocLW = "RPT_LW_ENGAGEMENTS"

stLinkCriteria = "[ENGAGEMENT_ACCESS_ID]=" & Me![Text0]

Select Case Me.List14 (//this is the vendor box//)
Case "PS"
stDocName = stDocPS
Case "CC"
stDocName = stDocCC
Case "IE"
stDocName = stDocIE
Case "LW"
stDocName = stDocLW
End Select

DoCmd.OpenReport stDocName, acViewReport, stLinkCriteria
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF
DoCmd.Close acReport, stDocName, acSaveYes
 
You could try adding a Case Else line to catch those that don't match your Me.List14 value:

Select Case Me.List14 (//this is the vendor box//)
...
Case Else
Msgbox "Can't find report for Vendor " & Me.List14 & "."
End Select

Or set stDocName to a default report before your Case statement or set after the Case Else.
 

You don't say which line of code is causing the error, but I'd guess it's the OutputTo method.
How about this?
Code:
DoCmd.OutputTo acOutputReport, stDocName, acFormatPDF[b][red], "Output File Name"[/red][/b]

Randy
 
sfm6 - The Case Else statement just makes an error pop each time I try to run a report even if there are values in the Vendor field. Also, if I set stDocName to a default report, it just opens that particular report for every instance. I want the code to open report LW is LW appears in the Vendor list box or CC if CC is appears in the Vendor list box (and so on).

Randy - the following code didn't do anything. Still gives the same error.

Thank you both for looking into this. I really appreciate your inputs.

 

On which line of code are you getting the error?


Randy
 
Was the error you were seeing after you added the Case Else line, did the error message start with "Can't find report for Vendor ...?" If so, then none of your choices in list14 were exactly PS, CC, IE, or LW, and stDocName will never be set.
So, the Vendor List (list14), does it have more values than just PS, CC, IE, and LW? You said "appears in." Does that mean you want to search the Vendor choice to see if it contains those 2 characters?
 
sfm6 - Yes, the error message was "Can't find report.." and after clicking "Ok", next error message popped up - "Needs a Report Name argument..."
The vendor box automatically populates based on some other criteria selected in the form. So the code above was meant to recognize the value in Vendor field, pull the particular report based on that value and other criteria in the form (like the ENGAGEMENT_ACCESS_ID)

Randy - not sure what line is giving me the error since only a dialog box opens up saying "Needs a Report Name Argumen..". It doesn't give me an error number like Access usually does and doesn't go into the debug mode.

Again, thanks for your help.
 

To troubleshoot this type of problem, I generally put a break point at or near the beginning of the code, then step through it, checking values as they update.

Put a break point inthe code by clicking on the gray bar to the left of the line of code where you want it to stop (a brown dot will appear).

Step through the code using the F8 key.
F5 will run the rest once you've found your error.

Remove the break point by clicking in the same spot.


Randy
 
Your code may have been meant to recognize the value in the Vendor field, but obviously it's not. If none of your choices in list14 are exactly PS, CC, IE, or LW, your report will fail. And if the Case Else statement is there, the Msgbox "Can't find report for Vendor " & Me.List14 & "." is telling you exactly what doesn't match those 4 values, and you'll need to change your code as needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top