W
Wendy
I have been at this a long time. I have reviewed all prior posts regarding
multi select list boxes to filter data for a report. I am just not "getting"
it.
I have a query "qryF2GLSummary" that includes "EffectiveDate" and "Step"
parameters. I have created a form that opens when the report rptF2 is run to
input these criteria. What I would like to do is include a multi select list
box where the user can select one or more or all GL Accounts from the
tblGL_Account. (This table has 8 records and two fields, GL_Account and
Description, both text fields)
I am trying to modify the examples I have seen, but am running into some
snags. I am working in 2003 but using 2000 file format. I have included the
code below.
Any help would be appreciated. Thank you
Private Sub OK_Click()
Dim varItem As Variant
Dim strWhere As String
Dim strDescrip As String
Dim lngLen As Long
Dim strDelim As String
Dim strDoc As String
strDoc = "qryF2GLSummary"
With Me.lstGLAccount
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
strDescrip = strDescrip & """&.Column (1, varItem) & "","
End If
Next
End With
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[GL_Account] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "GL_Account" & Left$(strDescrip, lngLen)
End If
End If
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition: strWhere
Exit Sub
End Sub
multi select list boxes to filter data for a report. I am just not "getting"
it.
I have a query "qryF2GLSummary" that includes "EffectiveDate" and "Step"
parameters. I have created a form that opens when the report rptF2 is run to
input these criteria. What I would like to do is include a multi select list
box where the user can select one or more or all GL Accounts from the
tblGL_Account. (This table has 8 records and two fields, GL_Account and
Description, both text fields)
I am trying to modify the examples I have seen, but am running into some
snags. I am working in 2003 but using 2000 file format. I have included the
code below.
Any help would be appreciated. Thank you
Private Sub OK_Click()
Dim varItem As Variant
Dim strWhere As String
Dim strDescrip As String
Dim lngLen As Long
Dim strDelim As String
Dim strDoc As String
strDoc = "qryF2GLSummary"
With Me.lstGLAccount
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
strWhere = strWhere & strDelim & .ItemData(varItem) &
strDelim & ","
strDescrip = strDescrip & """&.Column (1, varItem) & "","
End If
Next
End With
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[GL_Account] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "GL_Account" & Left$(strDescrip, lngLen)
End If
End If
If CurrentProject.AllReports(strDoc).IsLoaded Then
DoCmd.Close acReport, strDoc
End If
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition: strWhere
Exit Sub
End Sub