The following code takes the items selected in a listbox (PARTNOSELECT) on a form (START_UP) and puts them in a textbox (Text1). It places them into the textbox the following way: "PartNumber" OR "PartNumber" Or etc....
Private Sub Command19_Click()
Dim varRow As Variant
Dim strText As String
strText = ""
For Each varRow In Me!PARTNOSELECT.ItemsSelected
If strText = "" Then
strText = """" & Me!PARTNOSELECT.Column(0, varRow) & """"
Else
strText = strText & " Or """ & "" & Me!PARTNOSELECT.Column(0, varRow) & """"
End If
Next varRow
Text1.Value = strText
If strText <> "" Then
Text1.Value = strText
End If
Exit Sub
End Sub
I am then trying to run a query where the criteria is set to this textbox (Text1). This is what I have in the criteria part of the query:
=[Forms]![START-UP]![Text1]
Everytime I run it, the query comes back blank. I cannot figure out what is causing this problem. Is what I am doing even possible and the problem is due to the formatting of the data??? Any help would be appreciated!!!!!
Jennifer
Private Sub Command19_Click()
Dim varRow As Variant
Dim strText As String
strText = ""
For Each varRow In Me!PARTNOSELECT.ItemsSelected
If strText = "" Then
strText = """" & Me!PARTNOSELECT.Column(0, varRow) & """"
Else
strText = strText & " Or """ & "" & Me!PARTNOSELECT.Column(0, varRow) & """"
End If
Next varRow
Text1.Value = strText
If strText <> "" Then
Text1.Value = strText
End If
Exit Sub
End Sub
I am then trying to run a query where the criteria is set to this textbox (Text1). This is what I have in the criteria part of the query:
=[Forms]![START-UP]![Text1]
Everytime I run it, the query comes back blank. I cannot figure out what is causing this problem. Is what I am doing even possible and the problem is due to the formatting of the data??? Any help would be appreciated!!!!!
Jennifer