Open Report & Set Recordsource

schu7044

Registered User.
Local time
Yesterday, 19:18
Joined
Jan 31, 2008
Messages
14
Hi All: I am attempting to open a report in Access and set the recordsource using VBA.

Here is the code I am using:

Reports!rptGroupNoShow.Report.RecordSource _
= "SELECT * FROM qryGroup WHERE Left([TxGroup],3) = " & strGroup & " AND CIANoShow = True " _
& " AND ActiveInGroup = True"

I am receiving an error message that the rptGroupNoShow report does not exist.

Do I need to set something here?

Don
 
Why not just set the where in the code that opens the report?

DoCmd.OpenReport "rptGroupNoShow",acViewPreview,,"Left([TxtGroup],3)='" & strGroup & "' AND [CIANoShow]= True AND [ActiveInGroup]= True"

If qryGroup is set as the recordsource then opening the report thus allows you to filter the report without modifying the recordsource.
 
Thank you Bob. It does simplify things to do it this way.

However, I received a syntax error: missing operator

Don
 
Did you use the exact code I wrote, or did you modify it slightly? If modified, can you post the exact code you are trying to use?
 
Darn - I just am not seeing anything that should be generating that error.
 

Users who are viewing this thread

Back
Top Bottom