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