Vra

I have an Access application in which I need to do a 'mass-update'.

I have a form on which I have a dropdown, a listbox, and a checkbox. I also have a Update button, and when the user clicks it, I want to insert rows into my table with the same value for the dropdown and checkbox fields in all the rows, but I want different values for each row depending on the list items that were selected.

I know that multiple rows can be inserted into a table using the UNION SELECT statement, but how am I supposed to apply that with a listbox?

Can anyone please help?

Thanks in Advance

Was dit nuttig?

Oplossing

You can create an update statement for each item selected. For example:

strSQLBase="INSERT INTO Table (Field1, Field2, Field3) Values (" & Me.Dropdown _
    & "," & Me.CheckBox & ","
For Each itm In Me.ComboBox.ItemsSelected
    strSQL = strSQLBase & Me.ComboBox.Column(0, itm) & ")"
    CurrentDb.Execute strSQL
Next
Gelisensieer onder: CC-BY-SA met toeskrywing
Nie verbonde aan StackOverflow
scroll top