Link to home
Start Free TrialLog in
Avatar of DSE
DSE

asked on

Loop through elements of a continuous form

Hi,

Hope this doesn't sound too confusing...

How do I loop through a specific textbox on a form that is repeated any number of times? (continuous versus single page).

What I need to be able to do is check the value of each textbox.

Thanks in advance,

David.
Avatar of Paurths
Paurths

hi DSE,

here is an example that will 'visit' each textbox on a form, and display its data in a messagebox

Private Sub cmdLoopTXT_Click()
Dim ctrl As Control

    For Each ctrl In Me.Controls
        If TypeOf ctrl Is TextBox Then
            MsgBox ctrl.Value
            'do your action here
        End If
    Next ctrl
End Sub


cheers
Ricky
Avatar of DSE

ASKER

Hi Ricky,

I have tried to modify the code you wrote but I seem to be having some trouble implementing it. The repeated form has well over 100 records displayed but the code appears to only loop through 3 of them.

Can you help?

Thanks,

David.

This is the code I used:
------------------------

Dim ctrl As Control

For Each ctrl In Me.Controls

If TypeOf ctrl Is TextBox Then
   If SBSP = Null Then
      MsgBox "ok"
    End If
Else
End If

Next ctrl
Avatar of DSE

ASKER

sorry...SBSP is the name of the textbox that I want to specifically check the value of.
ASKER CERTIFIED SOLUTION
Avatar of Paurths
Paurths

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DSE

ASKER

Thanks a lot Paurths,

It worked great first time without changing a thing!

Thanks again,

David.