abenitez77
Registered User.
- Local time
- Today, 13:03
- Joined
- Apr 29, 2010
- Messages
- 141
I have a form which has a multilist box and i select more than 1 items on the list then click on a button and it saves the items to a text box. Then a query is ran. The query has the text box reference in the criteria. It ends up copying 0 records. I copied and pasted the values from the text box onto the query and ran it and it worked. What am i doing wrong?
Private Sub TestMultiSelect_Click()
Dim oItem As Variant
Dim sTemp As String
Dim iCount As Integer
iCount = 0
If Me!ItemNo.ItemsSelected.Count <> 0 Then
For Each oItem In Me!ItemNo.ItemsSelected
If iCount = 0 Then
sTemp = sTemp & Chr(34) & Format(Me!ItemNo.ItemData(oItem), "000000000") & Chr(34)
'sTemp = sTemp & Format(Me!ItemNo.ItemData(oItem), "000000000")
'sTemp = sTemp & Me!ItemNo.ItemData(oItem)
iCount = iCount + 1
Else
sTemp = sTemp & " or " & Chr(34) & Format(Me!ItemNo.ItemData(oItem), "000000000") & Chr(34)
'sTemp = sTemp & " or " & Format(Me!ItemNo.ItemData(oItem), "000000000")
'sTemp = sTemp & "," & Me!ItemNo.ItemData(oItem)
iCount = iCount + 1
End If
Next oItem
Else
MsgBox "Nothing was selected from the list", vbInformation
Exit Sub 'Nothing was selected
End If
Me!MySelections.Value = sTemp
' MsgBox (Forms!SelectItemNumbers.MySelections)
DoCmd.OpenQuery "QryLoadDeclineDtlForm", acViewNormal, acEdit
End Sub
Private Sub TestMultiSelect_Click()
Dim oItem As Variant
Dim sTemp As String
Dim iCount As Integer
iCount = 0
If Me!ItemNo.ItemsSelected.Count <> 0 Then
For Each oItem In Me!ItemNo.ItemsSelected
If iCount = 0 Then
sTemp = sTemp & Chr(34) & Format(Me!ItemNo.ItemData(oItem), "000000000") & Chr(34)
'sTemp = sTemp & Format(Me!ItemNo.ItemData(oItem), "000000000")
'sTemp = sTemp & Me!ItemNo.ItemData(oItem)
iCount = iCount + 1
Else
sTemp = sTemp & " or " & Chr(34) & Format(Me!ItemNo.ItemData(oItem), "000000000") & Chr(34)
'sTemp = sTemp & " or " & Format(Me!ItemNo.ItemData(oItem), "000000000")
'sTemp = sTemp & "," & Me!ItemNo.ItemData(oItem)
iCount = iCount + 1
End If
Next oItem
Else
MsgBox "Nothing was selected from the list", vbInformation
Exit Sub 'Nothing was selected
End If
Me!MySelections.Value = sTemp
' MsgBox (Forms!SelectItemNumbers.MySelections)
DoCmd.OpenQuery "QryLoadDeclineDtlForm", acViewNormal, acEdit
End Sub