Creating AfterUpdate events

workmad3

***** Slob
Local time
Today, 13:17
Joined
Jul 15, 2005
Messages
375
Well, I have a problem that I can solve by hand, but I really wouldn't want to.

I want to move my form calculation out of my form timer and into the AfterUpdate events of all my controls. Unfortunately, the number of controls is roughly speaking, huge, and spread across about 8 different subforms (I ran out of space to put them in on the main form, so subformed them all instead)

The calculation runs in under half a second, but at the moment it is being run every half a second in the timer, and this can cause some serious slowdowns. I would update the controls so that they update the relevant controls as needed, but this is about as huge a task as putting everything in manually.

So, any help on how to use an access routine to update my module code and add in some AfterUpdate events for controls would be appreciated :)
 
A alternate idea...
In form design view, select all the controls for which you'd like an AfterUpdate event handler to take control. On the events tab of the Multiple Selection property sheet, set the After Update property to a named function like "=MyAfterUpdate()"
Then, if need be, use the screen object to determine which control initiated the call.

Code:
Private Function MyAfterUpdate()
  Dim ctrl as Access.Control

[COLOR="Green"]  'run this custom routine for all controls[/COLOR]
  RecalcForm

[COLOR="Green"]  'run a routine on a different form[/COLOR]
  Forms("fMain").DoRecalc

[COLOR="Green"]  'identify control that initiated event here[/COLOR]
  set ctrl = Screen.ActiveControl
[COLOR="Green"]  'and run any required special handlers using the name of the control[/COLOR]
  Select Case ctrl.Name
    Case "chkSpecial1", "chkSpecial2"
[COLOR="Green"]       'call additional handlers for special calculations, 
       'passing in the AfterUpdated control if necessary
[/COLOR]       SpecialChkHandler ctrl
    Case "tbSomeText"
[COLOR="Green"]       'call the original AfterUpdate handler for this control[/COLOR]
       tbSomeText_AfterUdpate
    Case Else
[COLOR="Green"]       'and/or handle event for all controls that weren't handled above[/COLOR]
  End Select
End Function
 
Hmm... that sounds like it will work. Thanks for that :)

Will try it out this morning (Will need to change a couple of controls that already have an afterupdate event, but they are the minority thankfully)
 
Well, it didn't work :( So instead, I went through and added code to each controls afterupdate event to call the function. It works fine now, and I won't need to do that again in a hurry, thankfully :)

Thanks for trying though
 
What didn't work about it? Curious.
 

Users who are viewing this thread

Back
Top Bottom