Is it possible to raise the AfterUpdate event of a TextBox in a class module?
It's know it's not contained in the event list but there is maybe a workaround!
Cheers
Mats
Is it possible to raise the AfterUpdate event of a TextBox in a class module?
It's know it's not contained in the event list but there is maybe a workaround!
Cheers
Mats
Last edited by Mats Samson; 01-08-2012 at 06:25 PM.
No it is not, I'm afraid. That event actually belongs to the parent Control, but you cannot declare a generic Control WithEvents. Perhaps if you can tell us what you are trying to do specifically, we can come up with a workaround (though it will almost certainly be a little convoluted).
Good luck.
I read somewhere that it was possible to use RaiseEvent, but I believe it was for VB!
But basically I was trying to "compress" code putting several textbox AfterUpdates (quantity, purchase price, sales price, etc) in an order form in a Class module.
The Change event seems to work but it doesn't look that nice when values are recalculated with every new digit you type instead of after (e.g. just before) the textbox lose focus.
Well there is a long discussion on MrExcel about a similar issue (it was about the Exit event, but the same principles will apply) in this thread and you may be able to adapt the code there to your situation. Alternatively, if you only have a few controls, just use one update routine that you call from each control - that will minimise the code to some degree, albeit not as succinctly as a class.
Thanks,
Yes, I think I'll do!
I've found great fun in cutting code lines by using For.. To loops and especially if you're constructing (naming) variables, ranges and controls accurately you can just by passing an index from the control's real event procedure, control many events in a single "main" procedure.
Thanks for the guidance!
Regards
Mats
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks