Changing all records in many subforms with one Button

Staalung

New member
Local time
Today, 23:01
Joined
Sep 11, 2011
Messages
3
I need to change the values of a Combo Box in multiple records, in multiple subforms, based on a selection in a Combo Box on the main form.

I have been trying with a combination of "Do Until IsEmpty and Loop" and "IF, Then, Else", but not successful.

I can make "Do Until IsEmpty and Loop" working in a single subform, but when the subform is empty I get this error message. Run-time error '2448': You can't assign a value to this object.

The code I am using for the Loop is:
Do Until IsEmpty([frm_0_ImageID_Change_Order_Details])
Forms![frm_0_ImageID_Change]![frm_0_ImageID_Change_Order_Details].Form![Colour] = ColourSelect
frm_0_ImageID_Change_Order_Details.Requery
Loop

The reason for changing the values in the Combo Boxes in the subform is to clean up 6 years of old mistakes in the database.

I would really appreciate if some of you could guide me on the right track.

Thank You :)
 
you need to explain more since your explanation does not make sense.

You don't change values in comboboxes, you change them in the underlying table the combobox is bound to - or perhaps you mean you need to change the combobox rowsource - in which case you change the table the rowsource uses. Or maybe you are changing the field the combo is bound to? or some other property of the combobox?

provide some example data to clarify what it is you are trying to do, not how you are trying to do it. Show some examples of the existing data and what it needs to be changed to. If necessary, you can upload files providing you zip them first.
 
first of all you need recordset for each subform. then you issue .edit to sinal that you are editing the record. after, issue .update to save the edited record:


dim rs as dao.recordset
set rs=Forms![frm_0_ImageID_Change]![frm_0_ImageID_Change_Order_Details].Form.Recordset
with rs
if not (.bof and .eof) then .movefirst
while not .eof
.edit
![Colour] = ColourSelect
.update
.movenext
wend
end with
set rs=nothing
 
Thank you so much. I just copied your code to my Button, and it worked perfectly :)
 
youre welcome pal.
 

Users who are viewing this thread

Back
Top Bottom