Hello,
I have a small problem I can't resolve and I have now search the web up and down and back again so I hope this will be my final stop, at least for this problem
I got a Form with many TextBox's named "Date****" where **** is the record ID number.
So instead of having to type all the ID numbers into a criteria on a query I want it to look up all the TextBox's starting with "Date" on that Form and pull out the ID number and populate a Listbox with those records on another Form.
I have gotten so far that it goes through the From and pull out the ID number but it will only list one record in the Listbox and that is the last record it finds so I hope someone can help me find out how I get it to populate the Listbox with each record it find?
This is the code I use on the Form where the Listbox is.
Any help is appreciated
edit-
Working code if anyone one else should have the same problem.
edit-
I have a small problem I can't resolve and I have now search the web up and down and back again so I hope this will be my final stop, at least for this problem
I got a Form with many TextBox's named "Date****" where **** is the record ID number.
So instead of having to type all the ID numbers into a criteria on a query I want it to look up all the TextBox's starting with "Date" on that Form and pull out the ID number and populate a Listbox with those records on another Form.
I have gotten so far that it goes through the From and pull out the ID number but it will only list one record in the Listbox and that is the last record it finds so I hope someone can help me find out how I get it to populate the Listbox with each record it find?
This is the code I use on the Form where the Listbox is.
Any help is appreciated
edit-
Working code if anyone one else should have the same problem.
Code:
Private Sub Form_Load()
Dim ctl As Control
Dim IDNumber As String
Dim strSQl As String
Dim col1 As New Collection
Dim strIdNumbers As Variant
Dim arrValues() As String
Dim strIDs As String
For Each ctl In Forms!TestUI_B24_TL3OCU1.Controls
If (ctl.ControlType = acTextBox) Then
If Left(ctl.Name, 4) = "Date" Then
IDNumber = Right(ctl.Name, Len(ctl.Name) - 4)
col1.Add Array(IDNumber)
End If
End If
Next ctl
strSQl = "SELECT * FROM InstrumentList"
For Each strIdNumbers In col1
strIDs = strIDs & strIdNumbers(0) & ","
Next
If strIDs <> "" Then
strIDs = Left(strIDs, Len(strIDs) - 1)
strSQl = strSQl & " Where ID In (" & strIDs & ");"
End If
Me.B24_TL3_OCU1_List.RowSource = strSQl
End Sub
edit-
Last edited: