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!

It's a Method! Oh no it's not! Oh yes it is!

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
This is carrying on from thread705-307496 . It's kind of mutated into a different question so i thought I'd start a new thread.

If I set a variable(test) in a module to be a Control on an open form, when I check the debug window locals, I expand the variable and there amongst everything else is its AfterUpdate method.

Try as I might, I cannot reference this method in the form:

test.AfterUpdate

Where

controlName = "Cost Type"
Set test = Form_frmFindCourses(controlName)


I know you can successfully reference the AfterUpdate event of a control from a procedure in a module because this:

Form_frmFindCourses.Cost_Type_AfterUpdate

works fine.

So why can't you reference it the other way? I'd love to use the working method but I need to call different AfterUpdate methods depending on the controlName.

I know this can be solved using a Select Case statement but I can't understand why I can't do it this way when it all the evidence says it should!

Anyone know why?

Cheers,

Pete
 
Okay,just to update,tried using this

test.Properties.Application.Run (eventName)

which is brilliant since it wants the procedure name as a string which is what I need but it sas it can't find the procdeure ....whatever the eventName is....

The relevant procedures are public and in an open form so why can't Access find them?
 
Reaching a bit here, ... but ...

In some MS. A /VB /VBA objdcts, a propertry (method) doesn't exist until it has been instantiated. The tabledef "description" property is an example of this oddity. If you look at form/control events in design mode, you can see that most are 'greyed out' - these do not exist for the object. Some are normal text - and these have some code. If, in the browse mode of the object events, you click on one, it is shown withh the default 'stub' code - usually just the declaration and end statements. If you then 'browse' the events, you will see the newly instantiatedd stub as a 'normal'. I would "guess" that you could reference the event procedure of an object by using the code (class) module associated with the object and inserting what eveeer (legal) code you wanted and saving the module. I know that it is possible to insert code into a procedure, and that inserting a complete procedure results in the generation of that procedure in the module, but I have NOT done this specifically with event procedures for form/control objects.
MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top