Results 1 to 7 of 7
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,077

    Text box control shows zero length string as text is entered

    What event can be used instead of OnChange such that the control reference reflects that text has been entered? The OnChange event fires as expected with each keystroke but the control referenced as "tbNewDescription" does not reflect those completed keystrokes.

    Click image for larger version. 

Name:	CurrentEvent.jpg 
Views:	7 
Size:	57.4 KB 
ID:	22941

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    You have to use the .Text property in the change event.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,077
    I'll have to think of some other way, as the "CheckSaveStatus" function gets invoked when neither of the tb's referenced would have the focus. Access bombs with a 2185 if I try.
    Code:
    Private Function CheckSaveStatus() As Boolean
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    ' Check minimum requirements for a save operation
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    
    CheckSaveStatus = (Len(tbNewDate & "") > 0 And intNewTTypeID > 0 And _
                      (Len(Me.tbNewDescription.Text & "") > 0 Or Len(Me.tbNewMemo.Text & "") > 0))
    
    End Function


    This works as originally intended:
    Code:
    Private Sub tbNewMemo_Change()
    strMemo = Me.tbNewMemo.Text
    If CheckSaveStatus Then ToggleCmdVisibility
    End Sub
    
    Private Sub tbNewDescription_Change()
    strDescription = Me.tbNewDescription.Text
    If CheckSaveStatus Then ToggleCmdVisibility
    End Sub
    
    Private Function CheckSaveStatus() As Boolean
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    ' Check minimum requirements for a save operation
    '*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    CheckSaveStatus = (Len(tbNewDate & "") > 0 And intNewTTypeID > 0 And _
                      (Len(strDescription) > 0 Or Len(strMemo) > 0))
    
    End Function
    Both strDescription and strMemo are Dim'd String and are both initialized and refreshed as ZLS as appropriate.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    I assume you're using the change event so it changes the visibility while you're typing? The simplest solution is using the after update events rather than the change events, in which case the visibility wouldn't change until the user hit Tab or Enter. If you want to keep it as is, you might be able to use ActiveControl to determine which control has focus, and only use the text property on that one.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 7 64bit Access 2003
    Join Date
    Feb 2011
    Posts
    2,077
    I'll stay with the OnChange so that there's no dependency on the user to take any further action other than to stop typing to be complete. "Turning" on the "SAVE" command button when the required conditions have been met is what the user (read Carol) wants.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    The boss gets what the boss wants.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 05-29-2015, 10:21 AM
  2. Replies: 9
    Last Post: 03-15-2015, 10:37 PM
  3. Replies: 9
    Last Post: 04-18-2014, 08:51 PM
  4. Replies: 3
    Last Post: 12-22-2012, 05:33 PM
  5. Replies: 3
    Last Post: 01-05-2012, 10:47 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