Link to home
Start Free TrialLog in
Avatar of ACCESSIBLESOLUTIONS
ACCESSIBLESOLUTIONS

asked on

Printing in Access 2002

I have an application that has a custom query builder with a nice user interface.  The resultset is returned in a grid view in the detail section and usually has a horizontal scroll bar depeding on how many fields they include.

I am trying to find a way to print the resultset without actually formatting a report object and calling that.  Is there anyway to do this?  It currently calls the docmd.runcommand accmdprintpreview, but this cuts off some of the columns in the resultset.  Any input would be helpful...
Avatar of kevinredfern
kevinredfern

could you use a subreport, this way you would not have to format it, jus tset it to grow or shrink depending on the data that you ask it to bring in.

I hope i have understood your problem.
you could create a report object at runtime.  It's a lot of code, but it might work for you.  You could even get fancy in making it automatically switch to landscape if the number of fields would fit in portrait.

Mike
Avatar of ACCESSIBLESOLUTIONS

ASKER

The challenge is the number of columns vary (by design) with each run of the code so subforms or report objects can't be used.
How about just exporting it to Excel and printing it from there?

Mike
Interesting question since that is an option already on the form in addition to the print preview button. The problem is we have some users complaining Excel is an extra step they shouldn't be required to do - and everyone knows users are never wrong!
ASKER CERTIFIED SOLUTION
Avatar of Data-Man
Data-Man
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Data-Man: You wouldn't happen to have any sample code with the automation technique you could share by any chance. I'd like to try it.

Thanks,
Sorry I don't have any sample code....I have the code to create contracts via MS Word, but it is so customized for my client that if I post it here, it would require too much explaining for an EE question.

On the flip side, just create an object variable of type Excel.Application.
If you export the data to Excel and then turn on the macro recorder...do what you need to get the data printed correctly.  Stop the macro recording process and then copy and paste the code into Access and use your Excel object to prefix the code....you will have to tweak the code and also export the data into excel as part of the process, but this should be enough to get you started.

Mike
Thanks for the help on this