I am trying to investigate the use of a class sink on some controls.
Basically on entry to a combo, i want to run some code, on leaving, some more
code. I would like to learn this for all, essentially the controls first tho.
Many thanks.
I am trying to investigate the use of a class sink on some controls.
Basically on entry to a combo, i want to run some code, on leaving, some more
code. I would like to learn this for all, essentially the controls first tho.
Many thanks.
I have no idea what 'class sink' is. Use events to trigger code. Controls have OnGotFocus, OnLostFocus, and many other events.
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Basically how you do it is this...
my_form (form module)
Dim x as New super_ctl
x.set_ctl my_ctl1
x.OnClick = [EventProcedure]
super_ctl (class module):
Private WithEvents ctl AS Control ' or TextBox, Label, whatever
Public Sub set_ctl(my_ctl As Control)
Set ctl = my_ctl
End Sub
Private Sub ctl_Click()
' the event is sunken to this procedure
End Sub
The major benefit of all this is that you can add a ton of controls to an array within a "super_ctl" class module and have one "super_ctl" event procedure that all of the controls "whatever" event sink to.
For example, say you have 50 textboxes and you want each one to run DoCmd.RunCommand acCmdSaveRecord in the AfterUpdate event. Well instead of creating 50 event procedures, you just create a class module that has one event procedure that all the textboxes AfterUpdate event sinks to.