Accessing textbox value

chacal

Registered User.
Local time
Today, 14:42
Joined
Jun 1, 2005
Messages
40
Hi everyone,

I'd like to know if it is possible to access the value of every textbox that I have on my form in a for loop?

Because I Have about 30 textboxes in which the user can enter data, and I want to retreive all of these data and insert them in a matrix. But I don't know how to do that in coding because grouplevel is not accessible in forms.

I'm really lost

Thanks for your help!
 
Code:
Dim ctl As Control
Dim strText As String

For Each ctl In Me
    If ctl.ControlType = acTextBox Then
        strText = strText & Nz(ctl)
    End If
Next ctl

Set ctl = Nothing
 
Thanks for the code.

But Is there a way to access the textbox in an ordered way?
 
Are the textboxes names numbered?

If so then you can do the following.

Code:
Const TextBoxTotal As Long = 40
Dim strText As String
Dim lngCount As Long

For lngCount = 1 To TextBoxTotal
    strText = strText & Nz(Me("txtStuff" & lngCount))
Next lngCount
 
Good!!
It works perfectly.

Thanks a lot for your help!
I appreciate!
 

Users who are viewing this thread

Back
Top Bottom