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.
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.
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
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
ASKER
sorry...SBSP is the name of the textbox that I want to specifically check the value of.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot Paurths,
It worked great first time without changing a thing!
Thanks again,
David.
It worked great first time without changing a thing!
Thanks again,
David.
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