Just having a little bit of trouble changing report properties in Visual Basic. What I have is a report that can be run from two separate queries, and I want to dictate which query to run it off of using code.
Here is what I have so far:
Dim myRpt As Report
Set myRpt = Reports!rptRoomStatistics
myRpt.RecordSource = "qryArchivedRoomStatistics"
***Or it may be set to what below depending on where i want to pull the information
myRpt.RecordSource = "qryDayTableRoomStatistics"
I can compile the code fine, but then when I go to run it I get a run time error.
Run-time Error '2451'
The report name 'rptRoomStatistics' you entered is misspelled or refers to a report that isn't open or doesn't exist.
Now I've checked the spelling, and it's fine, so my next question is? Does this mean that I have to have the report open to change the "Record Source". It seems counter productive to have to open the report, change the record source, then requery/reopen the report.
Kinda baffled right now, and seeking outside input.
Thanks again to all who respond. FreeLancer