Hi All,
I'm trying to use a multi-select list box to determine the items in view on my form.
Selecting 1 Item Works!
Seclecting 2+ Items Doesn't Work - but there is no ERROR - each of my text boxes which show update, stay blank. The strange thing is that if I run the code and hover my curser over the string, it shows both items.
Have you seen this before, or could someone evaluate my code below - this (WHERE [strTeamName] = '" & strWhere & "' ) is the code that ultimately should populate my testboxes - ignore the ( and ) above. Code Below:
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.List355.ItemsSelected.Count = 0 Then
Exit Sub
End If
'add selected values to string
Set ctl = Me.List355
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ","
'Use this line if your value is text
'strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
' - - - - - -
Set db = CurrentDb
strSql = "SELECT Q1.strFullName, Q1.DetailsGeneral, Q1.strEmployeeLeft, Q1.strTeamName, Q1.DateBooked "
strSql = strSql & "FROM qry003CalenderLookupA AS Q1 "
strSql = strSql & "WHERE [strTeamName] = '" & strWhere & "' AND [strEmployeeLeft] = False AND (DateBooked Between " & lngFirstOfMonth & " And " & lngLastOfMonth & ") ORDER BY "
strSql = strSql & "DateBooked;"
Set rstEvents = db.OpenRecordset(strSql)
ANY IDEAS?
This is my code:
I'm trying to use a multi-select list box to determine the items in view on my form.
Selecting 1 Item Works!
Seclecting 2+ Items Doesn't Work - but there is no ERROR - each of my text boxes which show update, stay blank. The strange thing is that if I run the code and hover my curser over the string, it shows both items.
Have you seen this before, or could someone evaluate my code below - this (WHERE [strTeamName] = '" & strWhere & "' ) is the code that ultimately should populate my testboxes - ignore the ( and ) above. Code Below:
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.List355.ItemsSelected.Count = 0 Then
Exit Sub
End If
'add selected values to string
Set ctl = Me.List355
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ","
'Use this line if your value is text
'strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
' - - - - - -
Set db = CurrentDb
strSql = "SELECT Q1.strFullName, Q1.DetailsGeneral, Q1.strEmployeeLeft, Q1.strTeamName, Q1.DateBooked "
strSql = strSql & "FROM qry003CalenderLookupA AS Q1 "
strSql = strSql & "WHERE [strTeamName] = '" & strWhere & "' AND [strEmployeeLeft] = False AND (DateBooked Between " & lngFirstOfMonth & " And " & lngLastOfMonth & ") ORDER BY "
strSql = strSql & "DateBooked;"
Set rstEvents = db.OpenRecordset(strSql)
ANY IDEAS?
This is my code: