You are here:

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
   End If
'    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

Using MS Access

All Answers

Answers by Expert:

Ask Experts




I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.


I've been designing databases for over 25 years working with dBase, FoxPro, Approach and Access.

Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

Brooklyn College BA

©2017 All rights reserved.