Print Page | Close Window

ChooseReportFieldsRows.mdb (advanced)

Printed From: Roger's Access Library
Category: Roger's Access Library
Forum Name: Roger's Download Samples
Forum Description: A compendium of Microsoft Access 97 and 2000+ routines, each separated into its own sample database.
URL: www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=384
Printed Date: 28 Mar 2024 at 4:52pm
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: ChooseReportFieldsRows.mdb (advanced)
Posted By: Roger Carlson
Subject: ChooseReportFieldsRows.mdb (advanced)
Date Posted: 03 Aug 2008 at 10:31pm

Please consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm - find out why here .

ChooseReportFieldsRows.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 and then allows the user to specify the ROWS to be reported.

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. The user must then choose a Field to query on and then values to match in the listbox.

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 WHERE clause for the SQL statement is created from the values in the FieldName combo and Criteria listbox. Some complications: Since each data type is delimited differently, the routine which builds the Where clause tests for the datatype, thus Field combo box also has datatype in its row source.

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 max of 6 records which can be chosen. That number can be changed, but must be no higher than the max number of fields in the smallest table. In other words, if the smallest table has only 5 fields, the max 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 (34 KB):
http://www.rogersaccesslibrary.com/forum/uploads/5/ChooseReportFieldsRows97.zip - ChooseReportFieldsRows97.zip
Access 2000 DAO (30 KB): http://www.rogersaccesslibrary.com/forum/uploads/5/ChooseReportFieldsRows2k.zip - ChooseReportFieldsRows2k.zip



-------------
Consider donating $1 per sample downloaded, http://www.rogersaccesslibrary.com/whydonations.htm" rel="nofollow - find out why here .<



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net