Using MS Access/MS Access vba generate report online
In my form I have controls to filter a table A. As a result of pressing a button, code filters Table A and generate another table B as the filtered result. I want to have one more button control which will use Table B and prepare a report.
Please help me with this code.
So far I have tried following without success
If Not IsNull(Me.OpenArgs) Then
Me.RecordSource = Me.OpenArgs
' Me.RecordSource = Me.OpenArgs
DoCmd.OpenReport "ReportForReport", acViewPreview, , , , mSQL
I get a runtime error 3417
An action query cannot be used as a row source
my msql is
select tCopy.ADDRESS, tCopy.ASSET_CODE, tCopy.DEPT, tCopy.PROCESSOR, tCopy.LOCATION into forReport from inv_trans as tCopy where DEPT like "*a/c*" and PROCESSOR like "*p4*" and LOCATION like "*mahim*"
Are you sure that's what msql is? Is that the exact message? The message indicates that you are using an Action query as a ROWSOURCE. That would mean as the source for a combo or list box. If the message said RECORDSOURCE, then msql would probably be an action query. You mention that gnerate a table with the filtered result which indicates an Action query. But why generate a table when you can just use the query?
Hope this helps,
Microsoft Access MVP 2007
Author: Microsoft Office Access 2007 VBA