Looping through text boxes on form...?

pdbowling

Registered User.
Local time
Today, 23:13
Joined
Feb 14, 2003
Messages
179
Hello, Everyone.
I've got a form set up in 'Tabular' mode.

I would like to step through a particular column of text boxes and test the contents but don't know what to loop through. The text box I'm using is called Complaint.

Something like....

do while more Complaint
myVariable = complaint.text
test myVariable
next Complaint
loop

at the form_load event.

Since design view only shows one text box, I'm uncertain how to set up a loop through several of them.

Any suggestions for me?
Thanks all
PB
 
If I want to loop through specific textboxes I put a * in their Tag property.

The code then:

Code:
    Dim ctl As Control
    For Each ctl In Me
        If ctl.Tag = "*" Then
            ctl = "bla"
        End If
    Next
    Set ctl = Nothing


Or, all textboxes:

Code:
    Dim ctl As Control
    For Each ctl In Me
        If ctl.ControlType = acTextBox Then
            ctl = "bla"
        End If
    Next
    Set ctl = Nothing


Or, if the range is numbered

Code:
    Dim intCounter As Integer
    For intCounter = 1 To 10
        Me.Controls("txtTextBox" & intCounter) = "bla"
    Next intCounter
 
Last edited:

Users who are viewing this thread

Back
Top Bottom