VBA for setting values to all filtered data in subforms?

rodvaN

Registered User.
Local time
Today, 04:54
Joined
May 20, 2009
Messages
92
Hello there..
Is there a VBA for on click modifying all the filtered data in a subform ?

Me!Variable = False --- ( Alll the variables filtered in subform convert them to false? ).


Thanks in advance.
 
AFAIK there is not. I normally handle this by running an Update Query.
 
You could loop through all of the controls something like:
Code:
for each x in me.controls
   if isSomething(x) then
        ''Do something
   end if
next
 
You could loop through all of the controls something like:
Code:
for each x in me.controls
   if isSomething(x) then
        ''Do something
   end if
next

joh024,

Am I missing something with your code? How will your code handle multi records in a filtered sub form?
 
joh024,

Am I missing something with your code? How will your code handle multi records in a filtered sub form?

It seemed to me that the OP wanted to manipulate the controls on a subform as the records changed. So I was saying that the controls could be changed based on some criteria as the records change. The question was really general so I gave a general type of answer.
 
It seemed to me that the OP wanted to manipulate the controls on a subform as the records changed. So I was saying that the controls could be changed based on some criteria as the records change. The question was really general so I gave a general type of answer.

I see your point.

I just took the OP's "... all the filtered data ..." as meaning to mutli records, not multiple control.
 
Last edited:
So how should it be? Im confused.

Suppose that I got this button called, "checkin".
On click it then.. All the filtered data on subform in the field "Checkbox2" referring to that order will be marked as true.
 
You could loop through all of the controls something like:
Code:
for each x in me.controls
   if isSomething(x) then
        ''Do something
   end if
next

How would I use that?, on The button_Click() ???
Supposing my checkbox column is chkbox2
and my subform is "subfrm2"
How would I do it? :S
 
How would I use that?, on The button_Click() ???
Supposing my checkbox column is chkbox2
and my subform is "subfrm2"
How would I do it? :S

If you would like to control the subform through a button click then yes use the button_click event. Then if you only want to change one control like chkBox2 then you don't need the loop. Just set chkBox2.value = true or false depending on what you want to do.
 
If you would like to control the subform through a button click then yes use the button_click event. Then if you only want to change one control like chkBox2 then you don't need the loop. Just set chkBox2.value = true or false depending on what you want to do.

I need to use the loop for chboxing multiple filtered records on subform..
Please.. How I use that code?
 
You will have to make the code loop through the records in the sub form, no the control on the sub form.

With one line of code you can run an update query as previously suggest. An append query is also a lot faster and the user will not see the screen moving as each check box is checked. Either way will work, I just prefer the append query beause IMHO it is more efficient and more user friendly.
 
Sorry for my Ignorance, would you provide me information about append query or update query in my case?
Thanks in advance
 
UPDATE Mysubform SET ColumnID=MyValue

Is thatthe UPDAT E you are talking about right?
Would that update all the filtered records on the subform?
 
UPDATE Mysubform SET ColumnID=MyValue

Is thatthe UPDAT E you are talking about right?
Would that update all the filtered records on the subform?

yes, that is what I was referring to,

Since there is not a where clause, it would change EVERY record in the table

Try something like:

Code:
UPDATE Mysubform SET ColumnID=MyValue  [b]Where[/b] MyField = MyValue2

Since I do not know how your are filtering your sub form I do not know how to get the same filter added to the Where part of the Update query..
 
you could process the recordset but thats code

Code:
set rst=currentdb.openrecordset(your record source)

while not rst.eof
 if rst!whateverfield = whateversetting then do something
 rst.movenext
wend
 
you could process the recordset but thats code

Code:
set rst=currentdb.openrecordset(your record source)

while not rst.eof
 if rst!whateverfield = whateversetting then do something
 rst.movenext
wend

Thats what Im talking about :D.. gemma-the-husky..
Will I be able to check all the filtered checkboxes from the query that points to table?, without checking the ones that are not filtered?
Supposing my form is called "INDEX" and the Subform "Queryfiltersubform" that filters the data via the "Queryfilter" and the field name from the filtered checkboxes is "targetcheckbox"..
How I be able to put that In code?
Sorry for asking so much, I dont have so many knowledge in this and I gotta finish this project in 24 hours :S
Thanks HiTechCoach, joh024 and gemma-the-husky for answering.
 
Still stucked on this one.. could somebody explain me how that code works?.. does it works only for the filtered data on a query?
 

Users who are viewing this thread

Back
Top Bottom