Indirect Outside reference of a form control?

I need to access a form control from a procedure. For example, I have the form "Client" and the control "Name" then I can fill the form control like this:

Call FillForm ("Client")

Sub FillForm (FormName As Variant)
  Forms(FormName).name = "Test string"
end Sub

This works fine. However I now need to fill in many different controls of the same form and hence would like to concatenate the control as follows:

Call FillForm ("Client","Name")

Sub FillForm (FormName,FormCtrl As Variant)
  Forms(FormName).FormCtrl = "Test string"
end Sub

Obviously this does not work. Is there a way how i can reference the control from a function (i cannot use me.controls...

Thank you MIchael
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
It depends on bit on the point of origin of your code calling. If you are allready on the form, you can simply pass the form OBJECT to your function.
Sub FillForm (Frm as Form)
end Sub

Open in new window

You could call it like so:
  FillForm Me
mpimAuthor Commented:
Thank you but I'm calling it from an outside function. HOwever, I have found the solution for regular forms controls:

Forms(lFormName)("xF" & lFormNumber & "L" & ctr)  = "Test string"

This works fine. I still have not found the solution for addressing in the same way BUTTONS.. Any help would very much be appreciated!
Anders Ebro (Microsoft MVP)Microsoft DeveloperCommented:
You can reference a control by using the syntax

Open in new window

BUT this only works for forms that are not used as subforms. So if you wanted to use a subform it might be

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve JCommented:
It depends on bit on the point of origin of your code calling.
Use this syntax:

Open in new window

Yahoo mail login
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.