I have a long, multi-line text box that has a limited number of characters. I have another text box that I'd like to display the remaining characters as the user types in the first one. I'm able to get a variable to keep the count and I'm able to get the second text box to display the character count remaining. However, it only works if I move off the record and back on to it. It is not counting dynamically as the user types (see my code below).
What am I missing?
Private Sub txtReportComment_KeyPress(KeyAscii As Integer)
On Error GoTo Err_txtReportComment_KeyPress
Dim intEntryChar, intResponseChar, intEntryLength, intResponseLength, intMaxChars As Integer
' Set initial lenght limit
intMaxChars = 255
' Count characters currently in txtReportComment text box
intEntryLength = Len(Trim(Me.txtReportComment))
' Subtract character count from initial limit and populate to the txtEntryCharacters textbox
Me.txtEntryCharacters.Value = intMaxChars - intEntryLength
Exit_txtReportComment_KeyPress:
Exit Sub
Err_txtReportComment_KeyPress:
MsgBox Err.Description
Resume Exit_txtReportComment_KeyPress
End Sub
What am I missing?
Private Sub txtReportComment_KeyPress(KeyAscii As Integer)
On Error GoTo Err_txtReportComment_KeyPress
Dim intEntryChar, intResponseChar, intEntryLength, intResponseLength, intMaxChars As Integer
' Set initial lenght limit
intMaxChars = 255
' Count characters currently in txtReportComment text box
intEntryLength = Len(Trim(Me.txtReportComment))
' Subtract character count from initial limit and populate to the txtEntryCharacters textbox
Me.txtEntryCharacters.Value = intMaxChars - intEntryLength
Exit_txtReportComment_KeyPress:
Exit Sub
Err_txtReportComment_KeyPress:
MsgBox Err.Description
Resume Exit_txtReportComment_KeyPress
End Sub