Calling Procedures in a Subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form, Salesperson, that has a subform Salesperson_SalesGraph. The
SalesGraph subform is a pivot chart.

I'm having problems with trying to access items on the subform. The
weirdest part is that it seems to work if i call the event from form_open,
but doesn't work if i move the code to form_current. This won't work for me,
as i need the function called whenever i change rows.

The error received is: You entered an expression that has an invalid
reference to the property Form/Report.

First I had the code on the main form, accessing the chart object on the
subform but was getting errors that i couldn't access the form property in
the assignment, Set objChartSpace = Me.salesperson_salesgraph.Form.ChartSpace
(i tried a number of differnet ways, with !'s, with
Forms("SalesPerson_SalesGraph), etc.

Then i moved the code to the subform and now i'm just trying to call the
publically declared sub with the line:

Forms!Salesperson!Salesperson_SalesGraph.UpdateLegend
or
Me.Salesperson_SalesGraph.Form.UpdateLegend

The subform has a sub declared as:
Public Sub UpdateLegend()



Any thoughts?
Thanks!
-B
 
Hi Ben,

in order to call the procedure directly from an event
property, it needs to be defined as a FUNCTION, not a Sub

Public Sub UpdateLegend()

-->

Public Function UpdateLegend()

then, you can use
=UpdateLegend()

in your event property

you do not need this to be Public if it will be called from
the same form it is behind

'~~~~~~~~~~~~~~~~~~~

to call a sub in a subform from code behind the mainform,
try this:

Me!Salesperson_SalesGraph.Form.UpdateLegend()

I think you need to be in the code and not in the property

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
I don't think this is it.

I have changed it to a public function, and then the line
If Not Forms![PlayerTraining]![PlayerTrainingGraph].Form.UpdateLegend()
Then Exit Sub

still gives me the same error message: You entered an expression that had
an invalid reference to the property form or report.

Please note that i am calling the function in the subform from the event
CODE on the main form, not directly from the form property... Also please
note that it's the form that it can't find that is giving the error message,
not the function within the form...
 
Hi Ben,

without seeing your database, I am out of ideas... if you
would like to email it to me, I will have a quick look.
Please make sure it is stored in 2K or lower format

Tools, Database Utilities, Convert...

When you send it, please use the same subject line as this
thread so I know what it is. I will respond back to the
newsgroup


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
I don't think this is it.

I have changed it to a public function, and then the line
If Not Forms![PlayerTraining]![PlayerTrainingGraph].Form.UpdateLegend()
Then Exit Sub

still gives me the same error message: You entered an expression that had
an invalid reference to the property form or report.

Please note that i am calling the function in the subform from the event
CODE on the main form, not directly from the form property... Also please
note that it's the form that it can't find that is giving the error message,
not the function within the form...

:

Hi Ben,

in order to call the procedure directly from an event
property, it needs to be defined as a FUNCTION, not a Sub

Public Sub UpdateLegend()

-->

Public Function UpdateLegend()

then, you can use
=UpdateLegend()

in your event property

you do not need this to be Public if it will be called from
the same form it is behind

'~~~~~~~~~~~~~~~~~~~

to call a sub in a subform from code behind the mainform,
try this:

Me!Salesperson_SalesGraph.Form.UpdateLegend()

I think you need to be in the code and not in the property

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
I think i figured it out, i think it just didn't work from form_current.
Moved it from there somewhere else and seems fine.
 
Hi Ben,

glad you got it!

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 

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

Back
Top