RE: Limit selected criteria to a report Header
- From: Damian S <DamianS@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 15 Jan 2007 15:34:00 -0800
Hi Ralph,
When I want to list the report criteria in the header, I have a hidden text
field on the parameter form that I build with the description of the selected
options in teh On Click event of the button to fire your report. Then you
simply need to reference this hidden field in a single field on your header.
You can also set the field to "No criteria selected" if the user clears all
criteria.
Hope this helps.
Damian.
"Ralph Wischnewski" wrote:
I have a parameter form from which users have a choice to filter records and.
print a report of the filtered records. There are 8 fields on which users
can filter (they will typically use 2 or 3).
On the report header I would like to show the criteria selected. I started
off by adding text boxes on the report header with the control source
referring back to the parameter screen but because there are so many fields
to select from I want only those used to show on the report header.
If I can avoid listing all the criteria it would make the report header more
legible. However if I have to do this I would like to avoid the Report
Header showing #Name? when that particular field has not been chosen as a
criteria.
How do I do this?
If it helps the code for the filter is:
Private Sub CmdView_Click()
On Error GoTo Err_CmdView_Click
Dim db As Database
Dim rst As Recordset
'Clear the global Directive filter string
gstrDirView = ""
' and parse out a new one
'*****Set Status
If Not IsNothing(Me!CboStatus) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[Status] = " & Me!CboStatus
Else
gstrDirView = gstrDirView & " AND [Status] = " & Me.CboStatus
End If
End If
'*****Set Location ID
If Not IsNothing(Me!CboLoc) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[LocCust] =" & "'" & Me!CboLoc & "'"
Else
gstrDirView = gstrDirView & " AND [LocCust] =" & "'" &
Me!CboLoc & "'"
End If
End If
'*****Set Address
If Not IsNothing(Me!CboAddress) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[LocCust] =" & "'" & Me!CboAddress & "'"
Else
gstrDirView = gstrDirView & " AND [LocCust] =" & "'" &
Me!CboAddress & "'"
End If
End If
'********Set Date Comparison - Target
If Not IsNothing(Me!FromDate) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[TargetDate] >= " & "#" & Me!FromDate & "#"
Else
gstrDirView = gstrDirView & " AND [TargetDate] >= " & "#" &
Me!FromDate & "#"
End If
End If
If Not IsNothing(Me!ToDate) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[TargetDate] <= " & "#" & Me!ToDate & "#"
Else
gstrDirView = gstrDirView & " AND [TargetDate] <= " & "#" &
Me!ToDate & "#"
End If
End If
'********Set Date Comparison - Receipt
If Not IsNothing(Me!RecFrom) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[RecDate] >= " & "#" & Me!RecFrom & "#"
Else
gstrDirView = gstrDirView & " AND [RecDate] >= " & "#" &
Me!RecFrom & "#"
End If
End If
If Not IsNothing(Me!RecTo) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[RecDate] <= " & "#" & Me!RecTo & "#"
Else
gstrDirView = gstrDirView & " AND [RecDate] <= " & "#" &
Me!RecTo & "#"
End If
End If
'*********Set Report No
If Not IsNothing(Me!CboReportNo) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[ReportNo] =" & "'" & Me!CboReportNo & "'"
Else
gstrDirView = gstrDirView & " AND [ReportNo] =" & "'" &
Me!CboReportNo & "'"
End If
End If
'*********Set Elevator ID
If Not IsNothing(Me!CboUnit) Then
If IsNothing(gstrDirView) Then
gstrDirView = "[UnitID] = " & Me!CboUnit
Else
gstrDirView = gstrDirView & " AND [UnitID] = " & Me.CboUnit
End If
End If
'*********Set Responsibility ID
If Not IsNothing(Me!CboResp) Then
If Me!CboResp = -1 Then
If IsNothing(gstrDirView) Then
gstrDirView = "[ResponsibilityID]IS NULL"
Else
gstrDirView = gstrDirView & _
"And [ResponsibilityID] IS NULL"
End If
Else
If IsNothing(gstrDirView) Then
gstrDirView = "[ResponsibilityID] = " & Me!CboResp
Else
gstrDirView = gstrDirView & " AND [ResponsibilityID] = " &
Me.CboResp
End If
End If
End If
'*********If No criteria, then nothing to do
If IsNothing(gstrDirView) Then
MsgBox "No Criteria Specified.", vbExclamation, "TSSA Directives"
Exit Sub
End If
'********Search based on the string
Debug.Print gstrDirView
If IsLoaded("FDirView") Then
Forms!FDirView.SetFocus
DoCmd.ApplyFilter , gstrDirView
Else
Set db = CurrentDb
Set rst = db.OpenRecordset( _
"SELECT DISTINCTROW " & _
"QDirView.DirID " & _
"FROM QDirView " & _
"WHERE " & gstrDirView & ";")
DoCmd.OpenForm FormName:="FDirView", _
WhereCondition:=gstrDirView
Exit Sub
End If
DoCmd.Close acForm, "FDialogSelDir"
Exit_CmdView_Click:
Exit Sub
Err_CmdView_Click:
MsgBox Err.Description
Resume Exit_CmdView_Click
End Sub
- Follow-Ups:
- RE: Limit selected criteria to a report Header
- From: Ralph Wischnewski
- RE: Limit selected criteria to a report Header
- References:
- Limit selected criteria to a report Header
- From: Ralph Wischnewski
- Limit selected criteria to a report Header
- Prev by Date: Re: Sum function not working in Report group footer
- Next by Date: Re: Concatenate and Null Values -- Features
- Previous by thread: Limit selected criteria to a report Header
- Next by thread: RE: Limit selected criteria to a report Header
- Index(es):