W
WestWingFan
Hi!
Thanks in advance for your help. I have an issue and have not been able to
find a similar one on the forums.
I have a form which collects user requirements for a report through a
combobox (with a union all query id value = -1) and an option group (value =
5 is all subjects). The command button's on click event has this code:
Dim strWhere As String
If IsNull(Me.cboIndustrySelect) Then
MsgBox "Please select an Industry."
Me!cboIndustrySelect.SetFocus
Cancel = True
ElseIf IsNull(SubjectOption) Then
MsgBox "Please select a Subject."
Cancel = True
ElseIf Me.cboIndustrySelect = -1 And SubjectOption = 5 Then
DoCmd.OpenReport "rptMasterListofStandards", acViewPreview
ElseIf Not IsNull(Me.cboIndustrySelect) Then
If Me.cboIndustrySelect = -1 Then
strWhere = "[IndustryID]=*"
Else
strWhere = "[IndustryID]=" & Me.cboIndustrySelect
End If
If Not IsNull(SubjectOption) Then
If SubjectOption = 5 Then
strWhere = AddAnd(strWhere)
strWhere = "[JCSubjID]=*"
Else
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[JCSubjID]=" & Me.SubjectOption.Value
End If
End If
DoCmd.OpenReport "rptMasterListofStandards", acViewPreview, , strWhere
End If
I can run the report when: I select a industry from the combo box and a
subject area OR I select all industries and all subject areas. When I try to
select either all industries and a subject area OR an industry with all
subject areas, I get the same error about "missing operator in query
expression." Any ideas where I'm going wrong?
Thanks in advance for your help. I have an issue and have not been able to
find a similar one on the forums.
I have a form which collects user requirements for a report through a
combobox (with a union all query id value = -1) and an option group (value =
5 is all subjects). The command button's on click event has this code:
Dim strWhere As String
If IsNull(Me.cboIndustrySelect) Then
MsgBox "Please select an Industry."
Me!cboIndustrySelect.SetFocus
Cancel = True
ElseIf IsNull(SubjectOption) Then
MsgBox "Please select a Subject."
Cancel = True
ElseIf Me.cboIndustrySelect = -1 And SubjectOption = 5 Then
DoCmd.OpenReport "rptMasterListofStandards", acViewPreview
ElseIf Not IsNull(Me.cboIndustrySelect) Then
If Me.cboIndustrySelect = -1 Then
strWhere = "[IndustryID]=*"
Else
strWhere = "[IndustryID]=" & Me.cboIndustrySelect
End If
If Not IsNull(SubjectOption) Then
If SubjectOption = 5 Then
strWhere = AddAnd(strWhere)
strWhere = "[JCSubjID]=*"
Else
strWhere = AddAnd(strWhere)
strWhere = strWhere & "[JCSubjID]=" & Me.SubjectOption.Value
End If
End If
DoCmd.OpenReport "rptMasterListofStandards", acViewPreview, , strWhere
End If
I can run the report when: I select a industry from the combo box and a
subject area OR I select all industries and all subject areas. When I try to
select either all industries and a subject area OR an industry with all
subject areas, I get the same error about "missing operator in query
expression." Any ideas where I'm going wrong?