creating field name in do loop

G

Guest

I would like to loop through the fields in a table named G1, G2, G3,... in code and thought that could be accomplished by something of the sort
intCount=
stCount = ltrim(str(inCount)
Do while intCount < 2
If Me!G&stCount = forms!frmTest!G&stCount the
..
Endi
intCount = intCount+
stCount = ltrim(str(intCount)
Loop
What am I missing?
 
G

Guest

Hi Mary, I get the feeling that your source table design violates Normalisation rules....

Anyway you are using an explicit reference. Tr

Controls("G" & stCount) = forms!frmTest.controls("G" & stCount

you might also like to consider using an object variable to reference the other form for the sake of preformance efficienc

dim frm as for
set frm = forms!frmTes

then ..

Controls("G" & stCount) = frm.controls("G" & stCount

Luc
Jonatha

----- Mary wrote: ----

I would like to loop through the fields in a table named G1, G2, G3,... in code and thought that could be accomplished by something of the sort
intCount=
stCount = ltrim(str(inCount)
Do while intCount < 2
If Me!G&stCount = forms!frmTest!G&stCount the
..
Endi
intCount = intCount+
stCount = ltrim(str(intCount)
Loop
What am I missing?
 
A

Adrian Jansen

You need to refer to your textbox names in the string form:

dim strName as string

strName = "G" & stCount 'get the name as a string

Then

Me(stName) = forms!frmTest(strName)

You can do this without assigning the name to a string, I just did it this
way to make it clearer.

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
Mary said:
I would like to loop through the fields in a table named G1, G2, G3,... in
code and thought that could be accomplished by something of the sort:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top