Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caling a form event,from a module,using a string.

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
I'm trying to call the AfterUpdate event for a few controls in a form from a procedure in a module. I've successfully managed to reference a Control and some properties like so:

Form_frmFindCourses.Controls("EHCost Check").Value =

Form_frmFindCourses.Controls("EHCost Check").Enabled =

etc etc.

The "EHCost Check" will be replaced with controlName, a string variable which is passed to the procedure in the module. Hence why I can't use:

Call Form_frmFindCourses.EHCost_Check_AfterUpdate

So what I thought I could use is:

Call Form_frmFindCourses.Controls(controlName).AfterUpdate

I believed this should work since

Form_frmFindCourses.Controls(controlName).Enabled = False

works fine.

But I get the dreaded Object doesn't support this property or method error message. I can't understand why since all controlName variables passed are the names of controls that definitely have AfterUpdate as a method/property.

Can anyone advise?

Cheers,

Pete

 
Hi Pete

The after_update is only fired on an after_update event and not by calling the event. Access will not support this, as you clearly can read from the err msg.
However you could overcome this by makine a sub or function that does what the after_update event does for you.
The nice programmer would then call this sub or function from the after_update sub ;-)
 
So why I can call an After Update event like so:

Call Form_frmFindCourses.EHCost_Check_AfterUpdate

It works. I've checked.
 
Hi Pete

What can I say. I have also noted that some times call to a field event will work but not allways. So I never use them I make a function that does what I want and call that.
 
When access automatically brings up a list of properties/methods after pressing the . in a line of code, everything listed has one of two icons. I'm assuming the green icon means method.

I was just wondering if you could pass a reference of a method of a control, like the AfterUpdate some control on a form,to a procedure?
 
The green icon means function.
The little hand means property.

I would love to help you out, but I can only say what I would do in your situation.
If you want me to help further, I will gladly do so but I would have to see that actual base concerned.
Let me know and I shall gige you my email adr.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top