Writing data into text boxes on a form using a variable in the name

Slumdog

New member
Local time
Today, 23:49
Joined
Jan 28, 2015
Messages
3
Hi,

I'm trying to write code which writes text into text boxes on a form depending of certain content of other text boxes. The names of the text boxes are all very similar
F.i. R1, R2, R3 ...... R12 if the content of these boxes are empty then the content of the corresponding text boxes VR1, IR1, VR2, IR2, VR3, IR3.......VR12, IR12 should also be empty.

In fact I am trying to write something like this

DO UNTIL i=12
if me.R(i).value = "" then
me.VR(i).value = ""
me.IR(i).value = ""
endif
LOOP
But this isn't working

The solution below works but isn't a very nice one, writing 12 times the same code

if me.R1.value = "" then
me.VR1.value = ""
me.IR1.value = ""
endif

if me.R2.value = "" then
me.VR2.value = ""
me.IR2.value = ""
endif
......................

Thanks in advance,

Slumdog
 
try

Code:
 for i=1 to 12
    if me("R" & i)= "" then
        me("VR" & i)= ""
        me("IR" & i)= ""
    endif
next i
 
Repeating names usually indicates a database structure error.
 
I think in this case it is not the data but form control names that are repeating
 

Users who are viewing this thread

Back
Top Bottom