L
LFriend via AccessMonster.com
I'm trying to create a text box on a report header based on the items
selected on the multi-select box with the values listed one behind the
other (i.e., 440203, 440209, etc.) The multi-select box name is TempRCN.
The values are obtained from qryforMultiSelect.RCN. Any suggestions or
ideas will be greatly appreciated!!
This is the line of code set for the Multi-Select:
If Me.ReportType2.Value = "rptRCNSummary" Then
' Get the database and stored query
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
'Loop through the selected items in the list box and build a text string
For Each varItem In Me!TempRCN.ItemsSelected
StrCriteria = StrCriteria & ", '" & Me!TempRCN.ItemData(varItem) &
"'"
Next varItem
'If user leaves BL block blank
If Len(StrCriteria) = 0 Then
StrCriteria = "qryforMultiSelect.RCN Like '*'"
strSQL = "SELECT * FROM qryforMultiSelect " & _
"WHERE qryforMultiSelect.FY = [Forms]![frmRCNReport]![ReportFY]
" & _
"AND qryforMultiSelect.CATEGORY=[Forms]![frmRCNReport]!
[ReportCat] " & _
"AND " & StrCriteria & ";"
Else
'If user chooses one or more BLs
StrCriteria = Right(StrCriteria, Len(StrCriteria) - 1)
strSQL = "SELECT * FROM qryforMultiSelect " & _
"WHERE qryforMultiSelect.FY = [Forms]![frmRCNReport]![ReportFY]
" & _
"AND qryforMultiSelect.RCN IN(" & StrCriteria & ");"
End If
'Apply the new SQL statement to the query
qdf.SQL = strSQL
'Open the query
DoCmd.OpenQuery "qryMultiSelect"
'Empty the memory
Set db = Nothing
Set qdf = Nothing
DoCmd.Close acQuery, "qryMultiSelect"
End If
selected on the multi-select box with the values listed one behind the
other (i.e., 440203, 440209, etc.) The multi-select box name is TempRCN.
The values are obtained from qryforMultiSelect.RCN. Any suggestions or
ideas will be greatly appreciated!!
This is the line of code set for the Multi-Select:
If Me.ReportType2.Value = "rptRCNSummary" Then
' Get the database and stored query
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMultiSelect")
'Loop through the selected items in the list box and build a text string
For Each varItem In Me!TempRCN.ItemsSelected
StrCriteria = StrCriteria & ", '" & Me!TempRCN.ItemData(varItem) &
"'"
Next varItem
'If user leaves BL block blank
If Len(StrCriteria) = 0 Then
StrCriteria = "qryforMultiSelect.RCN Like '*'"
strSQL = "SELECT * FROM qryforMultiSelect " & _
"WHERE qryforMultiSelect.FY = [Forms]![frmRCNReport]![ReportFY]
" & _
"AND qryforMultiSelect.CATEGORY=[Forms]![frmRCNReport]!
[ReportCat] " & _
"AND " & StrCriteria & ";"
Else
'If user chooses one or more BLs
StrCriteria = Right(StrCriteria, Len(StrCriteria) - 1)
strSQL = "SELECT * FROM qryforMultiSelect " & _
"WHERE qryforMultiSelect.FY = [Forms]![frmRCNReport]![ReportFY]
" & _
"AND qryforMultiSelect.RCN IN(" & StrCriteria & ");"
End If
'Apply the new SQL statement to the query
qdf.SQL = strSQL
'Open the query
DoCmd.OpenQuery "qryMultiSelect"
'Empty the memory
Set db = Nothing
Set qdf = Nothing
DoCmd.Close acQuery, "qryMultiSelect"
End If