rdevriend
asked on
Input mask
When I want to restrict the input length of a field on a form to 30 characters, I can use :
>CCCCCCCCCCCCCCCCCCCCCCCCC CCCCC
Isn't their a simpler way to do this
It becomes annoying when the field is 100 characters long.
rene
>CCCCCCCCCCCCCCCCCCCCCCCCC
Isn't their a simpler way to do this
It becomes annoying when the field is 100 characters long.
rene
I think you set the length within the table's design (not the form) and if the textbox is linked to that field in the table it limits it automatically.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The field is not linked to a table field, so I cannot use this.
In the properties of the text box, set the Validation Rule to:
Len(Form!MyTextBox)<=30
Then set the Validation Text to something appropriate. Change MyTextBox to the name of your text box.
Len(Form!MyTextBox)<=30
Then set the Validation Text to something appropriate. Change MyTextBox to the name of your text box.
ASKER
It is a solution, but I don't like it. I would prefer that the user cannot type more characters as the length limits.
here is some hasty work i did. i think it works but please tidy it up if you use it. good luck.
/ j
Private Sub MyTextBox_KeyPress(KeyAsci i As Integer)
Me.Refresh
If Not IsNull(Me.MyTextBox) Then
Me.MyTextBox.SelStart = Len(Me.MyTextBox)
Me.MyTextBox.SelLength = 0
End If
If Len(Me.MyTextBox) > 30 Then
MsgBox "too long " & Len(Me.MyTextBox)
Me.MyTextBox= Left(Me.MyTextBox, 30)
Me.MyTextBox.SelStart = 30
Me.MyTextBox.SelLength = 0
End If
End Sub
/ j
Private Sub MyTextBox_KeyPress(KeyAsci
Me.Refresh
If Not IsNull(Me.MyTextBox) Then
Me.MyTextBox.SelStart = Len(Me.MyTextBox)
Me.MyTextBox.SelLength = 0
End If
If Len(Me.MyTextBox) > 30 Then
MsgBox "too long " & Len(Me.MyTextBox)
Me.MyTextBox= Left(Me.MyTextBox, 30)
Me.MyTextBox.SelStart = 30
Me.MyTextBox.SelLength = 0
End If
End Sub
ASKER
Auw, this has a big impact on the performance. After every keypress, this function is invoked.
Sorry, not a useful solution.
Sorry, not a useful solution.
If you are looking for a property setting that can be changed to give you the behaviour you want - there isn't one.
well, good luck in your search.
/ j
/ j
Dear expert(s),
A request has been made to close this Q in CS:
https://www.experts-exchange.com/questions/20553333/Close-Q-20547549.html
Without a response in 72 hrs, a moderator will finalize this question by:
- Saving this Q as a PAQ and refunding the points to the questionner
When you agree or disagree, please add a comment here.
Thank you.
modulo
Community Support Moderator
Experts Exchange
A request has been made to close this Q in CS:
https://www.experts-exchange.com/questions/20553333/Close-Q-20547549.html
Without a response in 72 hrs, a moderator will finalize this question by:
- Saving this Q as a PAQ and refunding the points to the questionner
When you agree or disagree, please add a comment here.
Thank you.
modulo
Community Support Moderator
Experts Exchange
I do not agree with this. Several answer was provided that would do what was asked but the questioner felt that they were not sufficient or did not fulfil his exact requirement - we are not responsible for the limitations of the technology. One of the provided workarounds would need to be adopted.
ASKER
Sorry, but nobody gave the solution I asked for. It were all workarounds. I cannot give points just because of the fact that you gave an answer.
I will leave this to modulo to judge.
ASKER
Yep, modulo, please advise.
Hi rdevriend,
I guess shanesuebsahakarn has a point.
You're asking for a workaround and multiple have been given.
In general a keypress function won't slow the form processing that much that a user will notice, but as you reject that option, the comment of shanesuebsahakarn "there isn't one" would be the "answer".
modulo
Community Support Moderator
Experts Exchange
I guess shanesuebsahakarn has a point.
You're asking for a workaround and multiple have been given.
In general a keypress function won't slow the form processing that much that a user will notice, but as you reject that option, the comment of shanesuebsahakarn "there isn't one" would be the "answer".
modulo
Community Support Moderator
Experts Exchange
ASKER
I do not agree with modulo, I never asked for a workaround, but I am no longer going to argue about just 50 points. If this is really the view from Modulo, I must accept Njelger's first answer.