Dynamic reference to control in other form

M

Mr. Smith

Hi.
I use this kind of approach to handle "dynamic" references to other controls

I.e set values in 12 different txtboxes
For i = 1 to 12
Me("txtMonthRevenue" & i & "").Value = somevalue
Next i

Thing is. I should want to do it against another form like this:

For i = 1 to 12
Me("txtMonthRevenue" & i & "").Value = Form_MainForm.txtMonth&i.Value
Next i

(Which ofcourse does not work....)

Is it possible to run through controls in another form on the same manner as
in Me("txt" & i &")?

Kind regards
Mr. Smith
 
T

Tony Toews [MVP]

Mr. Smith said:
Me("txtMonthRevenue" & i & "").Value = Form_MainForm.txtMonth&i.Value

Try Forms!MainForm!("txtMonth"&i).Value

Basically I just replaced Me with forms!MainForm!

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
M

Mr. Smith

Outstanding Tony!
Thanks a lot. Felt like a rookie when it worked.... but whatever :)

Kind regards
Mr. Smith
 
T

Tony Toews [MVP]

Mr. Smith said:
Outstanding Tony!
Thanks a lot. Felt like a rookie when it worked.... but whatever :)

Actually I had to experiment for a minute or so to ensure I did have
the right syntax. So don't feel bad. <smile>

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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