Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MultiSelect ListBox and ComboBox to populate field

Status
Not open for further replies.

bryn30

Technical User
Mar 5, 2001
57
US
I have a list of orders say 2000, and a few reps, about 12.
I am using a multiselect ComboBox (Extended) to select the order to be assigned. The ComboBox is a list of the reps. I am thinking a command button to execute the magic wand. How do I get the button to copy the ComboBox value (rep name) to the selected orders in the Multi-Select ListBox to the table that holds order information?
Loosing hair fast on this one. Please any help will be appreciated.
Thanks
 
We Did it!!!!!
Thank you jlitondo !!!!
it was small change in the single quotes being in the expression.

here is the final code that did it

Private Sub Command5_Click()


Dim rst As DAO.Recordset
Dim dbs As Database
Dim RepIdVar As String 'Variable to store the Rep ID
Dim OrderIdVar As String 'Variable to store the OrderID
Dim strSql As String
Dim varitem As Variant 'list box loop counter
Dim strCriteria As String

Set dbs = CurrentDb
Set rst = CurrentDb.OpenRecordset("Titan", dbOpenDynaset)

RepIdVar = Me.OCcombo

strCriteria = "[OC] = '" & RepIdVar & "'"

For Each varitem In WorkMang_Listbox.ItemsSelected

OrderIdVar = Me.WorkMang_Listbox.ItemData(varitem)

'Capture Criteria variables
strCriteria = strCriteria & " AND [ID] = " & OrderIdVar

'see if assignment already exists
rst.FindFirst strCriteria

If rst.NoMatch Then
'the combination of RepID and OrderId does not exist, build sql string to make assignment
strSql = "Update Titan Set [OC] = '" & RepIdVar & "' Where [ID] = " & OrderIdVar
dbs.Execute strSql
End If

Next varitem

rst.Close


'Debug.Print dbs.RecordsAffected
Set dbs = Nothing
End Sub


Thanks sooo much for sticking with me on this. you have been a tremendouse Help!

jlitondo Rocks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top