If you insert into a textbox tbxExample 81,32, 45,67
You can use a Split function to separate the values, then you can use those individual values
as you wish.
Here's a small example that may help
Code:
'---------------------------------------------------------------------------------------
' Procedure : tbxExample_AfterUpdate
' Author : mellon
' Date : 18/05/2015
' Purpose : Sample form with textbox to show use of split() to
' get individual values from a string of "csv" values.
' Once you have individual values you can use them/manipulate them as required.
'
'Revised: To show use of specific value in the textbox and also
' how to get individual values between the commas.
'---------------------------------------------------------------------------------------
'
Private Sub tbxExample_AfterUpdate()
Dim x As Variant
Dim i As Integer
Dim t1 As String
Dim t2 As String
10 t1 = "This is a mockedup SQL -"
20 t2 = "SELECT * FROM MyTable WHERE someIntfield In("
30 On Error GoTo tbxExample_AfterUpdate_Error
'use the string value in the textbox
40 Debug.Print "Sample using the text box string " & vbCrLf & vbCrLf & t1 & t2 & Me.tbxExample & ")" & vbCrLf & vbCrLf _
& "OR individual values beteeen commas " & vbCrLf
'OR
'separate the individual integers for individual processing/manpulation
50 If InStr(Me.tbxExample, ",") > 0 Then 'there is at least a comma in the txtbox
60 x = Split(Me.tbxExample, ",")
70 For i = LBound(x) To UBound(x)
80 Debug.Print i; x(i) & " " & x(i) ^ 3 & " is " & x(i) & " cubed"
90 Next i
100 Else
110 MsgBox "no values in textbox", vbOKOnly
120 End If
130 On Error GoTo 0
140 Exit Sub
tbxExample_AfterUpdate_Error:
150 MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure tbxExample_AfterUpdate of VBA Document Form_FormSampleTextBoxWithCSV"
End Sub
Output:
Sample using the text box string
This is a mockedup SQL -SELECT * FROM MyTable WHERE someIntfield In(81,32,45,67)
OR individual values between commas
0 81 531441 is 81 cubed
1 32 32768 is 32 cubed
2 45 91125 is 45 cubed
3 67 300763 is 67 cubed
NOTE: This was revised based on June7's comment and to show processing the individual values between the commas.