Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

Limit number of chars

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luis - 13 Jul 2005 16:58 GMT
Hello.
I have an unbound text box for users to input data. I want to limit the
input string to 50 chars. How do i do this on an unbound control?
I also like to create a label that shows the string length as the user types.

Thanks.

Luis
JackP - 13 Jul 2005 17:29 GMT
You could do this by using an input mask.

For example, an input mask of CCCCCCCCCC would allow any characters or
spaces up to a maximum of 10 in length to be included (but no minimum).
Increase the number of C's to increase the length allowed. (You can do this
more neatly - look up regular expressions)

Alternatively, you could have an after update event in your field which did
something like

if len(Me!MyField) > 50 then        
         me!MyField = left(Me!MyField,50)
         Msgbox "Your text has been truncated - only 50 characters allowed"
end if
fredg - 13 Jul 2005 18:22 GMT
> Hello.
> I have an unbound text box for users to input data. I want to limit the
[quoted text clipped - 4 lines]
>
> Luis

Here is one method.

You can set the unbound control's Validation Rule property to:
Len([ThisControlName])<=50
As Validation Text write whatever message you want.

If you also wish to have a label count the number of characters as
they are entered, add another unbound control.
Name it CountControl.
Set the Change event of the previous control to:
[CountControl] = Len(Me![ThiscontrolName].Text)
Signature

Fred
Please only reply to this newsgroup.
I do not reply to personal email.

Marshall Barton - 13 Jul 2005 18:35 GMT
>I have an unbound text box for users to input data. I want to limit the
>input string to 50 chars. How do i do this on an unbound control?
>I also like to create a label that shows the string length as the user types.

Use the text box's Change event:

If Len(Me.textbox.Text) > 50 Then
    Beep
    Me.textbox.Text = Left(Me.textbox.Text, 5)
End If
Me.textbox.Controls(0).Caption = Len(Me.textbox.Text)

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.