Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2005, 01:53 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default add fields to a report

Hi All!
I'm trying to create a report generator. I've got it to where it will create the report and set the record source and open it in design view. What I need to be able to do now is add the fields from the record source into the report detail section. The vba help doesn't help much on this one.

Can anyone help?

Thanks in advance!

dartcoach
__________________
dartcoach
 
Old March 9th, 2005, 02:22 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Question: Do you know which recordsource you are always going to have with this report generator? If so, you can do something like add unbound text boxes to your report, and then bind them at runtime. You can do this in the report detail's On Format event.

Perhaps you should discover the fields in a macro.

If you don't know the recordsource ahead of time, or if they are similar, you can still drop the text boxes on, then discover the field names with code and bind them that way. Like this:

   rs.Fields.Name(0) might give you the PK's field name. I know there is syntax for this. Then you can make the the label's text using code, etc.

HTH or gets you started.

mmcdonal
 
Old March 9th, 2005, 02:38 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Michael,

Sorry I didn't put another post on this one. I got the createreportcontrol command to work. What I have is a form that populates a listbox with all the tables in the current database. After picking a table - it populates another listbox with the columns in that table. This listbox is multiselect - so when I pick the columns I want on my report, it populates yet another listbox to allow me to sort by one of the fields I've selected for my report. After all that, I have a text box for a report title, then a command button to generate the report. The recordsource is generated, and within a loop, I create a textbox for each column, then open the report. It works great! The only issue is - since the user can pick as many fields as they want from the table, formatting the report to fit is quite an problem. I took the easy way out, I created a shortcut menu to allow the user to analyze with excel. That way they can format the report anyway they want to.

Thanks for your help!

Kevin

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
Add a Dropdownlist to update fields on a page cesemj ASP.NET 2.0 Basics 1 October 4th, 2007 11:24 AM
Add fields to a query stealthdevil Access VBA 3 November 16th, 2006 12:59 PM
How to add fields to an existing table using VBA donrafeal Access VBA 3 March 22nd, 2006 06:11 PM
replace fillin with ask fields & add references mariatherp Beginning VB 6 1 December 15th, 2004 06:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.