Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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 3rd, 2004, 07:26 PM
Authorized User
 
Join Date: Dec 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Report Heading Based On Selection Criteria Fo

Does anyone have any code samples of setting a report heading based on the criteria chosen by users on a criteria selection form for the report? Thanks for any help. Jim
 
Old March 4th, 2004, 12:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
If Form_YourForm.FieldList <> "" Then
    Me.GroupLevel(0).ControlSource = Form_YourForm.FieldList
Else
    Me.GroupLevel(0).ControlSource = "YourDefaultSortingField"
End If
If your Report is based on a saved query, you can use a combobox or listbox to display the fields from that query, and allow users to select one of those fields.

You should definitely put it in as an If statement, in case the user doesn't select a sort order.

Steven

I am a loud man with a very large hat. This means I am in charge
 
Old March 4th, 2004, 09:16 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Correct me if I'm misinterpreting, CloudNine, but Steven's answer is not what you're referring to. What I thought you meant was that you have this report with a header title, e.g. "My Report". You want "My Report" to change to "My Report based on X, Y, and Z" where X, Y, and Z are your criteria you set in the form that opened the report. Am I right? You just want your report title caption to change.

What you can do is on your form button's ON CLICK event (the button that opens the report), you can create a sentence based on your criteria. Say your criteria is this:

strCriteria = "[strCustID] = '" & Me.txtCustID & "' And [strCity] = '" & Me.txtCity & "'"

You can create an English translation like this

strRptTitle = "Customer ID = " & Me.txtCustID & " And City = " & Me.txtCity

Then open the report like this:

DoCmd.OpenReport "MyReportName", acPreview, , strCriteria, , strRptTitle

The strRptTitle is a passed argument. Then in the report heading's ON FORMAT event you put this (assuming the report title label is called "lblRptTitle"):

Me.lblRptTitle.Caption = Me.OpenArgs


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old March 4th, 2004, 12:36 PM
Authorized User
 
Join Date: Dec 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the replies, Steven and Greg. I think what Greg suggests is more along the lines of what I need. I have several checkboxes on the criteria form. When a checkbox is set to true (checked) one or more corresponding fields are enabled allowing the user to choose a criteria or an operator and then input a criterion, such as a date or a dollar amount. I need the report caption to reflect which checkboxes on the form are selected and the criteria that is set by the user. For example if the user checks the Criticality check box, they can choose High, Medium, or Low. If the user checks the Actual Date checkbox, they can choose =, <=, >= and then input a date. So if these 2 boxes are checked, the report caption would read something like "Projects Selection By Criteria = High, Actual Date <= 01/01/2003". Jim
 
Old March 4th, 2004, 06:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 308
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Once again, I've proven that skimming over a question will invariably lead to the wrong answer, you said "heading", I read "sort order" - I must have been exceptionally unclever at that point.


I am a loud man with a very large hat. This means I am in charge
 
Old March 4th, 2004, 08:09 PM
Authorized User
 
Join Date: Dec 2003
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I appreciate the info anyway. Sometimes what goes into the washer may have been better off dry-cleaned ;)

I'm ending up doing it with text boxes on the criteria form, concatenating those into another text box, and then referencing the form's text box on the report. Whatever works at this point. Jim





Similar Threads
Thread Thread Starter Forum Replies Last Post
'Search Form' based on criteria Grafixx01 Access 7 May 4th, 2007 09:39 AM
Selection criteria on index form - p422 kota BOOK: Access 2003 VBA Programmer's Reference 7 October 10th, 2006 11:39 PM
selection criteria... dbrook007 Other Programming Languages 0 February 21st, 2006 04:41 PM
how to have a selection of action pages for one fo gilgalbiblewheel Java GUI 0 September 17th, 2004 08:32 AM
Print selection criteria on report sjperl VB Databases Basics 1 May 3rd, 2004 11:41 PM





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