J
jutlaux
I have a combo box (Name = cboProjectStatus) that is used to define the
WhereCondition of a OpenReport command when a button is pressed (Name =
cmdOpenReportByStatus) with the below code. This part works. What I am now
trying to do is create a WhereCondition that is NOT what is selected in the
combo box. i.e. <> Me.cboProjectStatus. I have tried multiple iterations of
code to try this, but have not had any luck. How can I modify the below code
to make this work? Any help would be appreciated.
Private Sub cmdOpenReportByStatus_Click()
On Error GoTo Err_cmdOpenReportByStatus_Click
Dim stDocName As String
Dim strWhere As String
stDocName = "rptStandard"
strWhere = "1=1 "
If Not IsNull(Me.cboProjectStatus) Then
strWhere = strWhere & " And [strProjectStatus]= """ & _
Me.cboProjectStatus & """"
MsgBox strWhere
End If
DoCmd.Close
DoCmd.OpenReport stDocName, acPreview, , strWhere
Exit_cmdOpenReportByStatus_Click:
Exit Sub
Err_cmdOpenReportByStatus_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReportByStatus_Click
End Sub
WhereCondition of a OpenReport command when a button is pressed (Name =
cmdOpenReportByStatus) with the below code. This part works. What I am now
trying to do is create a WhereCondition that is NOT what is selected in the
combo box. i.e. <> Me.cboProjectStatus. I have tried multiple iterations of
code to try this, but have not had any luck. How can I modify the below code
to make this work? Any help would be appreciated.
Private Sub cmdOpenReportByStatus_Click()
On Error GoTo Err_cmdOpenReportByStatus_Click
Dim stDocName As String
Dim strWhere As String
stDocName = "rptStandard"
strWhere = "1=1 "
If Not IsNull(Me.cboProjectStatus) Then
strWhere = strWhere & " And [strProjectStatus]= """ & _
Me.cboProjectStatus & """"
MsgBox strWhere
End If
DoCmd.Close
DoCmd.OpenReport stDocName, acPreview, , strWhere
Exit_cmdOpenReportByStatus_Click:
Exit Sub
Err_cmdOpenReportByStatus_Click:
MsgBox Err.Description
Resume Exit_cmdOpenReportByStatus_Click
End Sub