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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Name parameter

Status
Not open for further replies.

isorders

IS-IT--Management
Dec 6, 2001
102
US

I can pass a parameter from the button click which opens a report which has this function referenced in a text box.

Function MHList(rept As String)

Dim oRS As Recordset
Dim sDistinctSQL As String
Dim sGeneralSQL As String
Dim sRecord
Dim sWONum() As String
Dim i As Integer
Dim strCSVals As String
Dim rptWO As String
MsgBox rept 'This works fine
rptWO = [Reports]![& rept &]![txtWorkOrderNo] 'This fails

The rept value though in the last line keeps failing with a 2451 The report name '& rept &' you entered is misspelled or refers to a report that isn't open or doesn't exist. If mouse over the rept in debug mode it show "thereport" so it is recognizing the name correctly, but the formating or something is off.
Thanks in advance!!
 
Try:
Code:
 rptWO = "[Reports]![" & rept & "]![txtWorkOrderNo]"
 
The Reports!Reportname! method of addressing controls unfortunately can't be used with ampersands to concatenate strings together, but a workaround that should work is:

rptWO = Reports(rept)![txtWorkOrderNo]

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top