All...
Looking for some suggestions. I use the code (below) to give users a running count of the text they have typed in a field. It writes the results to an unbound text box called CharCounter.
It works just fine. However, I've got dozens of text fields (60 altogether, actually) that I need to use this in and a dozen or so memo fields.
What I want is a way to call on a global function in the On Key up event (or where ever it would work best) that does the following:
BTW: I am using Access 2007
Thanks
Looking for some suggestions. I use the code (below) to give users a running count of the text they have typed in a field. It writes the results to an unbound text box called CharCounter.
It works just fine. However, I've got dozens of text fields (60 altogether, actually) that I need to use this in and a dozen or so memo fields.
What I want is a way to call on a global function in the On Key up event (or where ever it would work best) that does the following:
- Totals the number of the characters typed into a field
- Gives the number of remaining characters based on the length indicated in the table
- And makes character count always visible--with the current way I do this, the count goes way if you move to a different record and come back.
BTW: I am using Access 2007
Thanks
Code:
Private Sub Summary_KeyUp(KeyCode As Integer, Shift 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.Summary.Text))
' Subtract character count from initial limit and populate to the txtEntryCharacters textbox
Me.CharCounter.Value = intMaxChars - intEntryLength
DoEvents
Exit_txtReportComment_KeyPress:
Exit Sub
Err_txtReportComment_KeyPress:
MsgBox Err.Description
Resume Exit_txtReportComment_KeyPress