Results 1 to 3 of 3
  1. #1
    fritesmodern is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    13

    Triggering events for controls in a class

    I have a form with just one textbox (txtMyTextBox) which has the below code. I am trying to have the KeyPress event for the txtMyTextBox textbox triggered in the CControlEvent class. This is not happening due to some unknown reason.It is imperative for me to keep the collection object (ControlCollection) since I would like to have the KeyPress event triggered in the class for other textboxes.

    What am I missing here?

    Thanks in advance for your help


    **************FORM CODE****************

    Option Compare Database
    Option Explicit

    Private ControlCollection As Collection

    Private Sub Form_Current()
    Dim ctr As CControlEvent

    Set ctr = New CControlEvent
    Set ctr.setControl = txtMyTextBox
    ControlCollection.Add ctr

    End Sub

    Private Sub Form_Load()
    Set ControlCollection = New Collection
    End Sub

    ****************************************


    &&&&&&&&&&&&&&&&& CControlEvent Class Code &&&&&&&&&&&&&&

    Option Compare Database
    Option Explicit

    Private WithEvents textbox1 As TextBox


    Public Property Set setControl(ByVal aTextBox As TextBox)
    Set textbox1 = aTextBox
    End Property




    Private Sub textbox1_KeyPress(keyascii As Integer)
    textbox1.ForeColor = vbRed
    End Sub


    &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&
    Last edited by fritesmodern; 07-14-2015 at 01:41 PM. Reason: Made a mistake

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    "dirty" is not an event - it is a property (in A2010 - is A2013 different?) which other code can test and react accordingly.

  3. #3
    fritesmodern is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    May 2015
    Posts
    13
    Thanks for your response.

    I have modified the code. I am using the keypress event -see my original post; same results. The event keypress is not fired in the class.

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

Similar Threads

  1. Triggering Event
    By wes9659 in forum Forms
    Replies: 3
    Last Post: 02-04-2015, 09:46 AM
  2. Esc key not triggering Undo Event
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 01-20-2015, 10:41 AM
  3. MS Access triggering Outlook Security warning
    By Amiga1200 in forum Programming
    Replies: 5
    Last Post: 05-22-2014, 11:24 PM
  4. Triggering a form event from a report
    By Paul H in forum Forms
    Replies: 2
    Last Post: 10-12-2012, 09:48 AM
  5. Replies: 2
    Last Post: 01-17-2012, 01:17 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