Dynamic reference to control in other form

  • Thread starter Thread starter Mr. Smith
  • Start date Start date
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
 
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/
 
Outstanding Tony!
Thanks a lot. Felt like a rookie when it worked.... but whatever :-)

Kind regards
Mr. Smith
 
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/
 
Back
Top