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

    afterupdate, change, and dirty events wont fire in a Textbox

    I have a textbox bound to field in a table. The below code won't fire the afterupdate, change, and dirty events for my textbox.

    Me.txtMyTextbox= "New Data in My Textbox" // this won't fire the afterupdate, change, and dirty events. What am I missing?

    Is there a way to fire any of the aforementioned events by assigning a value directly to a textbox as in the above statement of code?



    Thanks in advance

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Afterupdate and change are events. Some controls have members for these events.

    Dirty is a property of a Form. You can check (read) the value of a Form's Dirty property and write to the Dirty property.

    If Me.Dirty = true then
    me.dirty = False
    end if

    You can use an event to fire some code. For instance, in the Click event of a button, you can save and commit values in bound controls to the table.

    sub MyButton_Click()

    if me.dirty then me.dirty = false

    end sub

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    AFAIK, events doe not execute when a control is changed by code. You can/could call events to execute code.

    The change event is mostly not used because it fires after each keypress. For example, if you wanted to limit what is entered into a textbox control to just even numbers, you could have code that checks to see if the character entered is an even number.

    I've only used the Dirty property at the form level to check if something changed on the form.

    Example code to call other code:
    Code:
    Private Sub Command0_Click()   'button name
        Me.txtMyTextbox= "New Data in My Textbox"
        Call txtMyTextbox_AfterUpdate
    End Sub
    
    
    Private Sub txtMyTextbox_AfterUpdate()
         Me.txtMyTextbox.BackColor = vbYellow
    End Sub

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by ssanfu View Post
    AFAIK, events doe not execute when a control is changed by code...
    That's the way I understand it.

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

Similar Threads

  1. Replies: 5
    Last Post: 04-30-2015, 01:50 AM
  2. Replies: 9
    Last Post: 09-02-2014, 10:56 AM
  3. Lookup status in textbox with AfterUpdate event
    By Animeonmymind in forum Forms
    Replies: 2
    Last Post: 02-25-2014, 08:19 PM
  4. Text Box wont allow me to change formatting
    By Chelcone in forum Forms
    Replies: 14
    Last Post: 04-20-2012, 07:33 AM
  5. Trying to fire event on record change
    By danielhowden in forum Forms
    Replies: 3
    Last Post: 05-13-2011, 06:30 AM

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