Results 1 to 3 of 3
  1. #1
    npsavidge is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    1

    Event Sink


    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.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    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.

  3. #3
    troggernaught is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    5
    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.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Trying something with the OnDeactivate event
    By eww in forum Programming
    Replies: 5
    Last Post: 06-16-2011, 10:44 AM
  2. Event Log strategy
    By kman42 in forum Database Design
    Replies: 1
    Last Post: 04-16-2011, 07:11 AM
  3. NotInList event
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 04-13-2011, 09:10 AM
  4. Help on an event...
    By allykid in forum Forms
    Replies: 4
    Last Post: 03-15-2011, 11:25 AM
  5. Replies: 21
    Last Post: 06-03-2009, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums