Results 1 to 12 of 12
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Text Box OnChange event always evaluates to NULL

    I have a pop-up form with a unbound text box (tbPWin) that has its OnChange Event set to the procedure below. I can't figure out why whenever I type into the text box that the value of the text box control is always NULL. I thought perhaps I needed to make reference to the controls value, Me.tbPWin.Value but that didn't make any difference in behavior.

    strPWin is Dim'd string and is global to the form's code sheet. The intent of the OnChange sub is to capture the input string while updating the display of the text box being replaced with dots. (Like most password entry menus)

    Code:
    Private Sub tbPWin_Change()
    
    If Not IsNull(Me.tbPWin) Then
        strPWin = strPWin & Right(Me.tbPWin, 1)
        Me.tbPWin = String(Chr(149), Len(strPWin))
    End If
    
    End Sub
    I'm not a seasoned user of OnChange so perhaps there's something about the event that I've not yet learned?



    Tying to use the KeyPress event below won't allow the setting of text in the text box......... blows up with data-type mismatch.

    Code:
    Private Sub tbPWin_KeyPress(KeyAscii As Integer)
    strPWin = strPWin & Chr(KeyAscii)
    Me.tbPWin = String(Chr(149), Len(strPWin))
    End Sub

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Bill
    Have you considered using the password input mask *****
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  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,518
    You have to use the Text property in the change event:

    http://www.baldyweb.com/ValueText.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Paul,
    Something else must be wrong. Assignment statement blows up on type mismatch.

    Chr(149) is a dot character and the String function returns a repetitive character string. strPWin is string and its current length in debug is one (1).

    Click image for larger version. 

Name:	008.jpg 
Views:	18 
Size:	29.5 KB 
ID:	34368

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Hi Colin, I'm not familiar with the "password input mask". Is that a built-in function for text box controls or some sort of technique used with the controls Mask property?

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Its built in. Click on Input Mask on the property sheet and select password from the list.
    Entered text will be shown as ****** as it is entered

    One word of warning.
    If secrecy is mission critical here, you need to be aware that anyone with access to the form design view can remove the input mask and view the text
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Works like a champ! Funny I'd never seen the password mask in the list when I've used the Input Mask for things like phone numbers, etc.

    One would have to find the accde and de-compile to gain access to the control.

    Thanks Colin,
    Bill
    (PS) I still want to lean what's wrong with the OnChange code in post #4 that Paul had looked at.

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Perfect!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by GraeagleBill View Post
    (PS) I still want to lean what's wrong with the OnChange code in post #4 that Paul had looked at.
    You've reversed the arguments, so you're passing the asterisk as the number, thus the type mismatch.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Paul, that was a test............ YOU PASSED!


  11. #11
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I believe you Bill!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by GraeagleBill View Post
    Paul, that was a test............ YOU PASSED!

    Hooray, it was bound to happen sooner or later!
    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. submit form event to check for null field
    By gunitinug in forum Access
    Replies: 3
    Last Post: 09-16-2017, 05:09 PM
  2. Replies: 6
    Last Post: 05-31-2017, 12:11 PM
  3. Replies: 4
    Last Post: 04-23-2016, 02:14 AM
  4. Add date OnChange Event - A to Z Walk Through
    By JeffG3209 in forum Programming
    Replies: 7
    Last Post: 08-12-2011, 04:40 PM
  5. Replies: 1
    Last Post: 06-22-2010, 03:15 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