PDA

View Full Version : Solved: Create report from SQL statement



hanta
05-26-2009, 09:49 PM
Hi all

The short description of my problem is, that I have to create a report out of a SQL statement. I create the SQL statement on the fly with code based on text fields and check boxes on a form and should get a report at the end. The statement is very complex, hence I can't use the built in report assistant.

Anyone with an idea how to do this?

Using Access 2007 on Windows XP

Thanks
Daniel

OBP
05-27-2009, 03:12 AM
Is this Solved or not?

hanta
05-27-2009, 03:17 AM
solved

but thankx

CreganTur
05-27-2009, 05:08 AM
Care to share your solution, so that others with a similar problem can benefit?

hanta
05-27-2009, 10:08 PM
I created a report which is linked to the query "qrSQL". Then I run the query with this code:

CurrentDb.QueryDefs("qrSQL").SQL = statement 'updates the query with my SQL statement
DoCmd.OpenQuery "qrSQL", acViewPreview 'opens the query in preview mode

Then I open the report which is linked to it and I have what I need. At lest nearly, still some things to solve like add and remove fields in the report on the fly, which gives me a little headache.

thx
Daniel