A
AccessDB
I created a list box that will let me select more than one, but the
problem is that when I run the report (a command button that I created
and works) the results are not what I want. Instead of showing just
the particular items that I selected it shows everything.
Here is the code that I have for my list box.
Private Sub cmdCreateReport_Click()
On Error GoTo Err_cmdCreateReport_Click
Dim strCriteria As String
Dim bolCriteria As Boolean
bolCriteria = False
strSQL = ""
strCriteria = ""
BeginSQL
strCriteria = "WHERE ("
If Not IsNull(Me.cboMfg.Value) Then
strCriteria = strCriteria & "(([new].[MANUFACTURER]) = '" &
cboMfg.Value & "') "
bolCriteria = True
End If
If Not IsNull(Me.ListApp.Value) Then
If Not bolCriteria Then
strCriteria = strCriteria & "(([new].[APPLICATION]) = '" &
ListApp.Value & "') "
Else
strCriteria = strCriteria & "AND (([new].[APPLICATION]) =
'" & ListApp.Value & "') "
End If
bolCriteria = True
End If
If bolCriteria Then
'if criteria was entered add it to the SQL string
strSQL = strSQL & strCriteria & ")"
End If
'close SQL and create query
EndSQL
ShowReport 'Me.cboSortBy1.Value, Me.cboSortBy2.Value
Exit_cmdCreateReport_Click:
Exit Sub
Err_cmdCreateReport_Click:
MsgBox Err.Description
Resume Exit_cmdCreateReport_Click
End Sub
problem is that when I run the report (a command button that I created
and works) the results are not what I want. Instead of showing just
the particular items that I selected it shows everything.
Here is the code that I have for my list box.
Private Sub cmdCreateReport_Click()
On Error GoTo Err_cmdCreateReport_Click
Dim strCriteria As String
Dim bolCriteria As Boolean
bolCriteria = False
strSQL = ""
strCriteria = ""
BeginSQL
strCriteria = "WHERE ("
If Not IsNull(Me.cboMfg.Value) Then
strCriteria = strCriteria & "(([new].[MANUFACTURER]) = '" &
cboMfg.Value & "') "
bolCriteria = True
End If
If Not IsNull(Me.ListApp.Value) Then
If Not bolCriteria Then
strCriteria = strCriteria & "(([new].[APPLICATION]) = '" &
ListApp.Value & "') "
Else
strCriteria = strCriteria & "AND (([new].[APPLICATION]) =
'" & ListApp.Value & "') "
End If
bolCriteria = True
End If
If bolCriteria Then
'if criteria was entered add it to the SQL string
strSQL = strSQL & strCriteria & ")"
End If
'close SQL and create query
EndSQL
ShowReport 'Me.cboSortBy1.Value, Me.cboSortBy2.Value
Exit_cmdCreateReport_Click:
Exit Sub
Err_cmdCreateReport_Click:
MsgBox Err.Description
Resume Exit_cmdCreateReport_Click
End Sub