passing a function a form input variable

  • Thread starter Thread starter Question Boy
  • Start date Start date
Q

Question Boy

I'm having a little difficulty passing a from varible as an input variable to
a function. the function is

Function ListFrmCtls(frm) As String

For Each ctl In frm.Controls

......

Now when I call it for the main form

ListFrmCtls(Forms![frm_Clients].Form

It works fine, but I need to run it for the subform as well and can't seem
to get the synthax right. Normally, I'd use something like

ListFrmCtls(Forms![frm_Clients]![frm_Clients Component Info].Form)

but it doesn't work and returns

"Run-time error 2465
.... can't find the field ... referred to in your expression"

What would be to proper synthax to use?

Thank you,

QB
 
Alex.

I am still getting the same error.

I was wondering since I am using my code in my main forms Form_Load event,
could this be part of my issue. Is a subform loaded before or after the main
form? if it doesn't get loaded until after then there is no way for me to
access it using this event, right? What event would I use in that case? Run
the code at load time only once.

Thank you

QB


Alex Dybenko said:
Hi,
try to use a variable first:

dim frm as Form

set frm=Forms![frm_Clients]![frm_Clients Component Info].Form

call ListFrmCtls(frm)

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

Question Boy said:
I'm having a little difficulty passing a from varible as an input variable
to
a function. the function is

Function ListFrmCtls(frm) As String

For Each ctl In frm.Controls

.....

Now when I call it for the main form

ListFrmCtls(Forms![frm_Clients].Form

It works fine, but I need to run it for the subform as well and can't seem
to get the synthax right. Normally, I'd use something like

ListFrmCtls(Forms![frm_Clients]![frm_Clients Component Info].Form)

but it doesn't work and returns

"Run-time error 2465
... can't find the field ... referred to in your expression"

What would be to proper synthax to use?

Thank you,

QB
 
Hi,
try to stop at
set frm=Forms![frm_Clients]![frm_Clients Component Info].Form
and check if frm got a reference to the form object

if you running from form_load - it should be ok, but you can use:

set frm=Me("[frm_Clients Component Info]").Form

and then make sure that frm_Clients Component Info is a name of subform
control

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com


Question Boy said:
Alex.

I am still getting the same error.

I was wondering since I am using my code in my main forms Form_Load event,
could this be part of my issue. Is a subform loaded before or after the
main
form? if it doesn't get loaded until after then there is no way for me to
access it using this event, right? What event would I use in that case?
Run
the code at load time only once.

Thank you

QB


Alex Dybenko said:
Hi,
try to use a variable first:

dim frm as Form

set frm=Forms![frm_Clients]![frm_Clients Component Info].Form

call ListFrmCtls(frm)

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com

Question Boy said:
I'm having a little difficulty passing a from varible as an input
variable
to
a function. the function is

Function ListFrmCtls(frm) As String

For Each ctl In frm.Controls

.....

Now when I call it for the main form

ListFrmCtls(Forms![frm_Clients].Form

It works fine, but I need to run it for the subform as well and can't
seem
to get the synthax right. Normally, I'd use something like

ListFrmCtls(Forms![frm_Clients]![frm_Clients Component Info].Form)

but it doesn't work and returns

"Run-time error 2465
... can't find the field ... referred to in your expression"

What would be to proper synthax to use?

Thank you,

QB
 
Back
Top