Is there a way to set up text boxes in Access forms as arrays for use in loops with VBA?
You can access the controls and iterate through them. Have to pick an iterable naming scheme.
Me.Controls("txt" & intloop)
I would disagree with serakfalcon in terms of requiring a certain naming schema to iterate through textboxes. The proper way would be to look at the control type. It should really be done like this:
Dim ctl As Access.Control
For Each ctl In Forms!MyForm.Controls
If ctl.ControlType = acTextbox Then
'...your code here.
End If
Next
This does not require a specific naming schema (not saying it is a bad idea, it isn't) and you know for sure the object is what you are expecting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With