I want to have a label or a unbound textbox which shows the number of characters written in another unbound text box (in the same form). The clue is to show how many char. left for SMS message. Someone who can help? Thanks!
Ole
Create the label and set it's visible property to false and then add this code to your unbound text box:
Private Sub YourTextBox_GetFocus()
YourLabel.Visible = True
If Nz(Len(YourTextBox), 0) = 0 Then
YourLabel.Caption = Format(0)
Else
YourLabel.Caption = Format(Len(YourTextBox))
End If
End Sub
Private Sub YourTextBox_Change()
If Nz(Len(YourTextBox), 0) = 0 Then
YourLabel.Caption = Format(0)
Else
YourLabel.Caption = Format(Len(YourTextBox))
If Len(YourTextBox) = YourMax + 1 Then
Call MsgBox("The maximum number of characters allowed in this field is YourMax. Please make appropriate changes to fit the field length. If you continue, Access will truncate your entry at YourMax!"
End If
End If
End Sub
Private Sub YourTextBox_LostFocus()
YourLabel.Visible = False
End Sub
Obviously, there are a variety of ways to do the error handling. What I did above, I feel, gives the user the maximum leeway. If you don't what to give them the maximum leeway, you will need to make changes. This should give you a start.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.