update multiple fields on table through a form

W

William

I need some direction on how to handle updating a table from a form using
code.
I have a list box on my form containing auto number values (1-40) listed
from the ID Field table
I also have a text box on the form bound to an attribute field on the same
table that the user will enter a value that will define a group multiple
selected values from the list box.

For example:
ID # 1,3,5,9 will all be assigned an attribute of "Group I"
and
ID # 2,12,36 will all be assigned an attribute of "Group II"

How can I update the attribute fields for each selected ID on the table
based on what is entered in the text box field?

Thanks in advance,

William
 
M

Michel Walsh

Hi,



Issue an individual update statement for each record:

Me.Dirty = False ' Avoid record locking ourselves out, save the actual record, if
dirty...
CurrentDb.Execute "UPDATE yourTable SET Attribute=" & NewAttribute & " WHERE ID IN(" &
ListOfIDtoModifyAttribute & ")"



Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top