I have a screen [switchboard] which supplies a call to a screen which takes the reporting facility and division from the user by them selecting radio buttons. I then want to build a "where clause" for the particular report that has been chosen from the switchboard and put the filter on the query for that report. Below is my confused attempt:
Me.Visible = False
'Check to see what the value of the check boxes are and set the
'appropriate value in the hidden control to pass to the query
If Me!grpDivision = 1 Then
Me.txt_Division = 2
ElseIf Me.grpDivision = 2 Then
Me.txt_Division = 61
Else
Me.txt_Division = 99
End If
'Check to see what the value of the check boxes are and set the
'appropriate value in the hidden control to pass to the query
If Me!grpFacilities = 1 Then
Me.txt_Facility = 1
ElseIf Me.grpFacilities = 2 Then
Me.txt_Facility = 10
Else
Me.txt_Facility = 99
End If
Build_Where_Clause
ReportName_Hold = "Admit Labels Master"
DoCmd.SelectObject acReport, "Labels Admit Master"
DoCmd.ApplyFilter ReportName_Hold, wherecondition:=WhereClause
DoCmd.OpenReport Me.txt_ReportName
Exit_cmdReportOptions_Click:
Exit Sub
Err_cmdReportOptions_Click:
MsgBox Err.Description
Resume Exit_cmdReportOptions_Click
End Sub
'Function IsFormOpen(strForm As String)
' ' Is the form open?
' IsFormOpen = (SysCmd(acSysCmdGetObjectState, acForm, strForm) <> 0)
'End Function
Rem*
Rem*******************************************************************
Rem*
Rem* Build the Where clause for the report
Rem*
Rem*
Rem*
Rem*******************************************************************
Rem*
Private Sub Build_Where_Clause()
WhereClause = " (((EVENT.EVENT_TYPE)=10 Or (EVENT.EVENT_TYPE)=30) AND ((EVENT.EVENT_CREATE_DT)>=[Enter Processing Date] And (EVENT.EVENT_CREATE_DT)<DateAdd(""d"",[Enter Processing Date],1)) AND ((EVENT.EVENT_SOURCE)=""G"") "
If Forms!sbfReport_Selection_Criteria.txt_Division = 1 Then
WhereClause = WhereClause & " AND location_rprt_div = 1 "
End If
If Forms!sbfReport_Selection_Criteria.txt_Division = 2 Then
WhereClause = WhereClause & "location_rprt_div = 2 "
End If
If Forms!sbfReport_Selection_Criteria.txt_Facility = 1 Then
WhereClause = WhereClause & "locaton_rpt_fac_id = 1"
End If
If Forms!sbfReport_Selection_Criteria.txt_Facility = 2 Then
WhereClause = WhereClause & "locaton_rpt_fac_id = 2"
End If
If Forms!sbfReport_Selection_Criteria.txt_Division = 99 Then
If Forms!sbfReport_Selection_Criteria.txt_Facility = 99 Then
WhereClause = WhereClause & "1 = 1"
End If
End If
End Sub
What I get is "You can't use the applyfilter action on this window " with a bunch of meaningless text after that.
Me.Visible = False
'Check to see what the value of the check boxes are and set the
'appropriate value in the hidden control to pass to the query
If Me!grpDivision = 1 Then
Me.txt_Division = 2
ElseIf Me.grpDivision = 2 Then
Me.txt_Division = 61
Else
Me.txt_Division = 99
End If
'Check to see what the value of the check boxes are and set the
'appropriate value in the hidden control to pass to the query
If Me!grpFacilities = 1 Then
Me.txt_Facility = 1
ElseIf Me.grpFacilities = 2 Then
Me.txt_Facility = 10
Else
Me.txt_Facility = 99
End If
Build_Where_Clause
ReportName_Hold = "Admit Labels Master"
DoCmd.SelectObject acReport, "Labels Admit Master"
DoCmd.ApplyFilter ReportName_Hold, wherecondition:=WhereClause
DoCmd.OpenReport Me.txt_ReportName
Exit_cmdReportOptions_Click:
Exit Sub
Err_cmdReportOptions_Click:
MsgBox Err.Description
Resume Exit_cmdReportOptions_Click
End Sub
'Function IsFormOpen(strForm As String)
' ' Is the form open?
' IsFormOpen = (SysCmd(acSysCmdGetObjectState, acForm, strForm) <> 0)
'End Function
Rem*
Rem*******************************************************************
Rem*
Rem* Build the Where clause for the report
Rem*
Rem*
Rem*
Rem*******************************************************************
Rem*
Private Sub Build_Where_Clause()
WhereClause = " (((EVENT.EVENT_TYPE)=10 Or (EVENT.EVENT_TYPE)=30) AND ((EVENT.EVENT_CREATE_DT)>=[Enter Processing Date] And (EVENT.EVENT_CREATE_DT)<DateAdd(""d"",[Enter Processing Date],1)) AND ((EVENT.EVENT_SOURCE)=""G"") "
If Forms!sbfReport_Selection_Criteria.txt_Division = 1 Then
WhereClause = WhereClause & " AND location_rprt_div = 1 "
End If
If Forms!sbfReport_Selection_Criteria.txt_Division = 2 Then
WhereClause = WhereClause & "location_rprt_div = 2 "
End If
If Forms!sbfReport_Selection_Criteria.txt_Facility = 1 Then
WhereClause = WhereClause & "locaton_rpt_fac_id = 1"
End If
If Forms!sbfReport_Selection_Criteria.txt_Facility = 2 Then
WhereClause = WhereClause & "locaton_rpt_fac_id = 2"
End If
If Forms!sbfReport_Selection_Criteria.txt_Division = 99 Then
If Forms!sbfReport_Selection_Criteria.txt_Facility = 99 Then
WhereClause = WhereClause & "1 = 1"
End If
End If
End Sub
What I get is "You can't use the applyfilter action on this window " with a bunch of meaningless text after that.