loop through text boxes on form?

joebox8

New member
Local time
Today, 09:31
Joined
Jul 7, 2011
Messages
6
Hi... I'm new to access! Hopefully someone can help.

My DB has one table, Its not very big however I have roughly 50 fields in it.
32 of the fields are named x1, x2, x3, x4, ....x32(corresponding to 32 text boxes on my form)
I have Tagged each text box with "T". How would i work it so I can only get the average(or std_dev) of only the tagged text boxes that have a numeric value greater than 0.00???

I realize there are a few ways of doing this however im struggling with it. Here's what i think...
Loop through each text box, If greater than 0.00 then increment a count(say C) then at the end divide my total by (32 - C)?

Or should I do this from the Table instead of the form? through a query? or how could i phrase DAvg so the criteria would pick out the nonNull Tagged textbox values??
Please help!!!
 
you can loop through all controls using the for each loop
To clear every textbox on the current form:
Code:
    Dim ctl As Control
   
    For Each ctl In Me.Controls
        If TypeOf ctl Is TextBox Then
            ctl.Value = Null
        End If
    Next ctl

HTH:D
 

Users who are viewing this thread

Back
Top Bottom