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 / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

Limiting a TextBox to 127 characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff - 17 Nov 2005 17:10 GMT
Hello,

What I am looking for is a way to limit a user to having more than 127
characters in a Text Box.  I know the simple way is to have an Input Mask.
But I dont want to use the Input Mask Property, I can explain why if needed.

So one way I know you can is in the KeyDown Event...

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
   If Len(txtNotes.Text) > 126 And Then  KeyCode = 0
End Sub

This works if the user tries to TYPE more than 127 characters.  But it does
not help if the Users COPIES and PASTEs text into the Field.  So for example
if there are 100 characters in there & they Copy some large text from
somewhere else & then Right click & Paste into this one it will take it.  How
can I prevent this from happening ?  But want to allow to Paste if total is
less than 127 characters.

I know I can also use the BeforeUpdate & AfterUpdate Events to trim down the
large amount of Text after the fact, but what I prefer is to just not allow
it from the begining.

So some way to prevent users from Pasting more than 127 Characters.

Any help would be greatly appreciated.

Thank You,
Jeff
Ken Snell [MVP] - 17 Nov 2005 17:20 GMT
Only way I know is to use the BeforeUpdate or AfterUpdate events....
Signature


       Ken Snell
<MS ACCESS MVP>

> Hello,
>
[quoted text clipped - 32 lines]
> Thank You,
> Jeff
Jeff - 17 Nov 2005 17:37 GMT
Ken thank you, but as I mentioned the BeforeUpdate & AfterUdate Events are
not triggered until the user moves the focus away from the control.

I want to prevent before this happens... any way ?

Thank you,
Jeff

> Only way I know is to use the BeforeUpdate or AfterUpdate events....
> > Hello,
[quoted text clipped - 33 lines]
> > Thank You,
> > Jeff
Jeff - 17 Nov 2005 17:43 GMT
Sorry I figured it out, can use the CHANGE EVENT as that is triggered & then
I just used =Left(...,127)

Thank you

> Hello,
>
[quoted text clipped - 25 lines]
> Thank You,
> Jeff
Rick Brandt - 18 Nov 2005 12:42 GMT
> Hello,
>
> What I am looking for is a way to limit a user to having more than 127
> characters in a Text Box.  I know the simple way is to have an Input Mask.
> But I dont want to use the Input Mask Property, I can explain why if needed.

Any reason you don't just use a Text DataType in the table with the length set
to 127?

Signature

I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com

 
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.