Results 1 to 3 of 3
  1. #1
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150

    MS Access - Help with Textbox Change Event - Not firing code

    Hi,

    Scratching my head over how to get my textbox change event to disable my option group.

    The logic should be...

    If user enters text, the second the textbox receives its first character, it should disable the option group.

    Inversely...

    If textbox becomes blank at any point in time, the option group should become enabled again.


    I've been at this for hours now. I believe the problem roots within the Option Group not having focus,which is why it won't change the option group enabled property immediately - only until the user first switches focus out of the textbox.

    Attached is example with code. I welcome you to try to solve this issue! Thanks for your time and efforts in advance.

    Regards,

    TBChange.accdb

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The code is firing. Set a breakpoint and step through code and you will see it execute.

    Value is default property of data control. Value property is not set until control loses focus. Value is the property your function tests.

    Consider following use of Text property without the UDF:

    Code:
    Private Sub tbText_Change()
    If Len(Me.tbText.Text & "") = 0 Then
        Me.OpGroup.Enabled = True
    Else
        Me.OpGroup.Enabled = False
    End If
    End Sub
    or simply:

    Private Sub tbText_Change()
    Me.OpGroup.Enabled = Len(Me.tbText.Text & "") = 0
    End Sub
    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
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Quote Originally Posted by June7 View Post
    The code is firing. Set a breakpoint and step through code and you will see it execute.

    Value is default property of data control. Value property is not set until control loses focus. Value is the property your function tests.

    Consider following use of Text property without the UDF:

    Code:
    Private Sub tbText_Change()
    If Len(Me.tbText.Text & "") = 0 Then
        Me.OpGroup.Enabled = True
    Else
        Me.OpGroup.Enabled = False
    End If
    End Sub
    or simply:

    Private Sub tbText_Change()
    Me.OpGroup.Enabled = Len(Me.tbText.Text & "") = 0
    End Sub

    June7,

    Thanks for your reply. I did know the code was firing (easy to determine), I just wasn't sure how to get around the focus issue with .Value property.

    The .Text property works great! Thank you!

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

Similar Threads

  1. Replies: 7
    Last Post: 05-18-2018, 01:38 AM
  2. Key Press Event and/or Key Up Event not firing as expected
    By GraeagleBill in forum Programming
    Replies: 7
    Last Post: 01-16-2018, 04:11 AM
  3. Navigation subform event firing
    By Frank2306 in forum Forms
    Replies: 4
    Last Post: 05-11-2017, 07:10 AM
  4. Combo box On Dbl-Click event not firing
    By GraeagleBill in forum Forms
    Replies: 5
    Last Post: 12-26-2016, 06:45 PM
  5. Key Down event not firing
    By GraeagleBill in forum Programming
    Replies: 4
    Last Post: 11-18-2016, 12:45 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