Control Value in Array (1 Viewer)

Liv Manto

Registered User.
Local time
Today, 20:45
Joined
Apr 26, 2001
Messages
266
CONTROL'S VALUE IN AN ARRAY - HELP

My objective is to copy all the values from one record (from a form) to another new record.

I am thinking of using the For each ctl.. Next Ctl.

First I would create an array with upperbound of the number of textbox controls.

then For each control, I would assign the the value of the control to the array, one by one.

My problem, everytime I get to the part

X(i) = ctl.value, There is nothing in there.


dim ctr as integer 'ctr= number of controls
dim i as integer, ctl as control

i = 0

ReDim x(ctr)
MsgBox "X(CTR) " & x(ctr)
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
MsgBox "ctl.value " & ctl.Value
x(i) = ctl.Value
i = i + 1
MsgBox "x(i) ) " & x(i)
' THE ABOVE GIVES ME x(i)) WITHOUT THE VALUE OF THE x(i)

End If
Next ctl

???
 

Abby N

Registered User.
Local time
Today, 20:45
Joined
Aug 22, 2000
Messages
123
I don't see anything that sets the value for your variable ctr. Try adding this line somwhere before your ReDim statement:

ctr = Me.Controls.Count

~Abby
 

Users who are viewing this thread

Top Bottom