Roger's Access Library Homepage
Forum Home Forum Home > Roger's Access Library > Roger's Download Samples
  New Posts New Posts RSS Feed - ChooseReportFields.mdb (intermediate)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

>
Want a good read? Try The Summer of His Life (available on Amazon!)

ChooseReportFields.mdb (intermediate)

 Post Reply Post Reply
Author
Message
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP


Joined: 20 Feb 2008
Status: Offline
Points: 261
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Topic: ChooseReportFields.mdb (intermediate)
    Posted: 03 Aug 2008 at 10:36pm

Please consider donating $1 per sample downloaded, find out why here.

ChooseReportFields.mdb

This sample very roughly illustrates how to create a query programmatically which chooses the FIELDS to be reported on a report based on the selected values of a multi-select list box.

The user selects the table to be reported and is presented with a list of fields for the table. All tables which the developer wants in the list must have a "tbl" prefix. The user then selects the Fields he wants in his report in the multi-select list box. Pushing the RunReport button creates a query which selects the field names chosen and renames them with generic field name (Field0, Field1, etc). For the unselected fields, the field is set to NULL so the user will not be prompted for empty fields. Each field that is chosen has its corresponding record set to the field number in the TableFields table.

The report has field headings that are read from the TableFields name field using DLookup and using the Indexx field in the where clause. The report title is taken from the cboTable combo box in the form. The report has a maximum of 6 records which can be chosen. That number can be changed, but must be no higher than the maximum number of fields in the smallest table. In other words, if the smallest table has only 5 fields, the maximum number of fields in the report should be 5.

This form very roughly illustrates how to create a query programmatically which chooses the FIELDS to be reported on a report based on the selected values of a multi-select list box. The user selects the table to be reported and is presented with a list of fields for the table. All tables which the developer wants in the list must have a "tbl" prefix. The user then selects the Fields he wants in his report in the multi-select list box. Pushing the RunReport button creates a query which selects the field names chosen and renames them with generic field name (Field0, Field1, etc).
 
For the unselected fields, the field is set to NULL so the user will not be prompted for empty fields. Each field that is chosen has its corresponding record set to the field number in the TableFields table. The report has field headings that are read from the TableFields name field using DLookup and using the Indexx field in the where clause. The report title is taken from the cboTable combo box in the form. The report has a maximum of 6 records which can be chosen. That number can be changed, but must be no higher than the maximum number of fields in the smallest table. In other words, if the smallest table has only 5 fields, the maximum number of fields in the report should be 5.
 
Disclaimer: This is not designed to be an all encompassing generic report generator. It is designed to illustrate how you can add flexibility for a limited number of report options. I have made many assumptions which may not be true for your application. 

Download
Access 97 (51 KB):
ChooseReportFields97.zip
Access 2000 DAO (51 KB): ChooseReportFields2k.zip

Consider donating $1 per sample downloaded, find out why here.<
Back to Top
Sponsored Links
>
Want a good read? Try The Summer of His Life (available on Amazon!)

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.