Dear Shankar, Unbound text box: limiting entry length
Access automatically prevents you entering too much text if a control is bound to a field. Unbound controls can be limited with the *Input Mask *- one "C" for each possible character. However, the input mask has side effects such as *appending underscores* to the Text property and making it *difficult to insert* text into the middle of an entry. For a cleaner result, use a combination of the control's *KeyPress* and * Change* events. Here's how. 1. *Paste* the two "subs" from the end of this article into a module. Save. 2. *Call LimitKeyPress() in* your text box's *KeyPress* event. For example, to limit a control named "City" to 40 characters, its KeyPress event procedure is: Call LimitKeyPress(Me.City, 40, KeyAscii) 3. *Call LimitChange() in* your text box's *Change* event. For the same example, the Change event procedure is: Call LimitChange(Me.City, 40) 4. *Repeat* steps 2 and 3 for other unbound text/combo boxes in your application. See below link for more details http://allenbrowne.com/ser-34.html -- Thanks & regards, Noorain Ansari *http://excelmacroworld.blogspot.com/*<http://excelmacroworld.blogspot.com/> *http://noorain-ansari.blogspot.com/* <http://noorain-ansari.blogspot.com/> On Tue, Dec 13, 2011 at 1:53 PM, Shankar Bheema <shankar.n...@gmail.com>wrote: > Dear Experts > > How to assign max length for a textbox control in MSAccess 2003. In > properties, no such facility is available. How can it be assigned through > Code. > > regards > shankar sb > > -- > FORUM RULES (934+ members already BANNED for violation) > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > > 2) Don't post a question in the thread of another member. > > 3) Don't post questions regarding breaking or bypassing any security > measure. > > 4) Acknowledge the responses you receive, good or bad. > > 5) Cross-promotion of, or links to, forums competitive to this forum in > signatures are prohibited. > > NOTE : Don't ever post personal or confidential data in a workbook. Forum > owners and members are not responsible for any loss. > > > ------------------------------------------------------------------------------------------------------ > To post to this group, send email to excel-macros@googlegroups.com > -- FORUM RULES (934+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com