I was hoping someone could help me "see the light" with the issue I'm having. I've provided the vba code below. The vba code is looping through a multilist box. There are two text boxes hidden on the form. TextBox1 is a string of item numbers, TextBox2 is a string of location codes that correspond to the item numbers in TextBox1.
Example:
TextBox1: 095716, 167017, 180886, 180887
TextBox2: A404A,A404A,A103A,A102A
Item # 095716 needs to be updated to location A404A .... Item # 180887 needs to be updated to location A102A.
I've been updating the location code by having a user select a location from a combo box and then all items for the location were being displayed in the multilist box. Then based on which items the user selected I used
CODE
InStr([Forms]![ReceivingPropertyTransferForm]![TextBox1],[ItemNumber])
as an expression in my update query to update the location code field selected in the combo box for each item number that appears in TextBox1.I had to change that design and now display the location code as column 2 in the multiselect box. I want the user to select the row in the multiselect box and then have it update for each item number (column 0) the location code based on column 2 in the multiselect box. I have the two strings (TextBox1, TextBox2), but I don't know how to use the TextBox2 string as update criteria and match it to the item number in TextBox1.
CODE
If IsNull(Me.TB_Email.Value) Then
MsgBox "Unable to complete Property Transfer(s) approval." & vbNewLine & "You must enter your work e-mail address in order to view pending transfer(s)."
Exit Sub
Else
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Dim strSQL2 As String
Dim lngLen As Long
Dim lngLen2 As Long
Set frm = Forms!ReceivingPropertyTransferForm!
Set ctl = frm!LB_MutliSelectItem
For Each varItem In LB_MutliSelectItem.ItemsSelected
strSQL = strSQL & Me!LB_MutliSelectItem.ItemData(varItem) & ","
strSQL2 = strSQL2 & Me!LB_MutliSelectItem.Column(2, varItem) & ","
Next varItem
lngLen = Len(strSQL) - 1
lngLen2 = Len(strSQL2) - 1
TextBox1 = Left$(strSQL, lngLen)
TextBox2 = Left$(strSQL2, lngLen2)
MsgBox "Unable to complete Property Transfer(s) approval." & vbNewLine & "You must enter your work e-mail address in order to view pending transfer(s)."
Exit Sub
Else
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Dim strSQL2 As String
Dim lngLen As Long
Dim lngLen2 As Long
Set frm = Forms!ReceivingPropertyTransferForm!
Set ctl = frm!LB_MutliSelectItem
For Each varItem In LB_MutliSelectItem.ItemsSelected
strSQL = strSQL & Me!LB_MutliSelectItem.ItemData(varItem) & ","
strSQL2 = strSQL2 & Me!LB_MutliSelectItem.Column(2, varItem) & ","
Next varItem
lngLen = Len(strSQL) - 1
lngLen2 = Len(strSQL2) - 1
TextBox1 = Left$(strSQL, lngLen)
TextBox2 = Left$(strSQL2, lngLen2)