473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

A97: Simplest way to limit unbound textbox to 200-chars entered MAX

MLH
Can I somehow set a max length of chars entered
into an unbound textbox control?
Feb 13 '06 #1
12 2420
On Mon, 13 Feb 2006 12:12:55 -0500, MLH wrote:
Can I somehow set a max length of chars entered
into an unbound textbox control?


The below code will limit the number of characters to 10.
Code the unbound text control's Change event:

Private Sub ControlName_Change()
If Len([ControlName].Text) = 11 Then
MsgBox "No more then 10 characters are permitted."
[ControlName].Text = Left([ControlName].Text, 10)
End If

End Sub

Change [ControlName] to whatever the actual name is of your unbound
control.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Feb 13 '06 #2
MLH wrote:
Can I somehow set a max length of chars entered
into an unbound textbox control?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

One way is in the BeforeUpdate event of the control:

Private Sub TextBoxName_BeforeUpdate(Cancel As Integer)

If Not IsNull(Me!TextBoxName) Then
If Len(Me!TextBoxName)>200 Then
MsgBox "Too Long. Must be <= 200 characters"
Cancel = True
End If
End If

End Sub
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ/DGP4echKqOuFEgEQI2/ACg1OrLoU4dmt08QDGLHaI8hLoDu/oAoKP2
e/mwmh05UNq1fZERevGI9g3Z
=389V
-----END PGP SIGNATURE-----
Feb 13 '06 #3
MLH wrote:
Can I somehow set a max length of chars entered
into an unbound textbox control?


I might as well throw in what I use:

http://groups.google.com/group/comp....a0bbcaf3f5428c

James A. Fortune
CD********@FortuneJames.com

Feb 13 '06 #4
MLH
Thx. Was hoping that I could monitor this during actual entry
of characters into the textbox. IE, on the 200th character, it
wouldn't allow subsequent keystrokes to place chars in the
control.
Feb 13 '06 #5
MLH wrote:
Thx. Was hoping that I could monitor this during actual entry
of characters into the textbox. IE, on the 200th character, it
wouldn't allow subsequent keystrokes to place chars in the
control.


You could also set the Input Mask to:

_;;

Enter the underline character 200 times instead of the 1 time in the
example.

When the user tries to enter the 201 character a beep will sound.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Feb 13 '06 #6
Lots of good solutions - here's my favorite:
Private Sub Notes_memo_AfterUpdate()
Me.Notes_memo = Left(Me.Notes_memo, 200)
End Sub

Private Sub Notes_memo_KeyPress(KeyAscii As Integer)
If Len(Me.Notes_memo.Text) > 200 Then
If KeyAscii > 31 Then KeyAscii = 0
End If
End Sub

I use this belt/suspenders approach in case someone does a copy/paste into
the control.

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
"MLH" <CR**@NorthState.net> wrote in message
news:8q********************************@4ax.com...
Thx. Was hoping that I could monitor this during actual entry
of characters into the textbox. IE, on the 200th character, it
wouldn't allow subsequent keystrokes to place chars in the
control.


Feb 13 '06 #7
MLH
Had already tried that. Presented its own twists 'n turns.
Using something like &x200;;" " - the user finds his insertion
point at the END of all 200 spaces. Wouldn't be so bad if I
could make that insertion point somehow sit at the BEGINNING
of all those spaces. Haven't quite figured that one out yet.
Feb 13 '06 #8
MLH wrote:
Had already tried that. Presented its own twists 'n turns.
Using something like &x200;;" " - the user finds his insertion
point at the END of all 200 spaces. Wouldn't be so bad if I
could make that insertion point somehow sit at the BEGINNING
of all those spaces. Haven't quite figured that one out yet.


I haven't tried it for that specific case but this post may help:

http://groups.google.com/group/micro...b8f5b992c1b5d4

James A. Fortune
CD********@FortuneJames.com

Feb 14 '06 #9
On Mon, 13 Feb 2006 14:01:38 -0500, MLH wrote:
Thx. Was hoping that I could monitor this during actual entry
of characters into the textbox. IE, on the 200th character, it
wouldn't allow subsequent keystrokes to place chars in the
control.


You can count the number of characters as you enter them.
Add another unbound text control.

Change the previous Change event code to:

Private Sub ControlName_Change()

' To count up to the maximum number of characters
[OtherControl] = len(Me![ControlName].Text)

' Or to count down from 10 to the remaining number of characters
' [OtherControl] = 10 - len(Me![ControlName].Text)

If Len([ControlName].Text) = 11 Then
MsgBox "No more then 10 characters are permitted."
[ControlName].Text = Left([ControlName].Text, 10)
End If

End Sub
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Feb 14 '06 #10
Randy Harris wrote:
Private Sub Notes_memo_AfterUpdate()
Me.Notes_memo = Left(Me.Notes_memo, 200)
End Sub

Private Sub Notes_memo_KeyPress(KeyAscii As Integer)
If Len(Me.Notes_memo.Text) > 200 Then
If KeyAscii > 31 Then KeyAscii = 0
End If
End Sub

I use this belt/suspenders approach in case someone does a copy/paste into
the control.


Excellent idea. I think I need to add the AfterUpdate suspenders to
what I have to ensure my backside stays covered when the belt breaking
copy/paste occurs.

James A. Fortune
CD********@FortuneJames.com

Feb 14 '06 #11
MLH wrote:
Had already tried that. Presented its own twists 'n turns.
Using something like &x200;;" " - the user finds his insertion
point at the END of all 200 spaces. Wouldn't be so bad if I
could make that insertion point somehow sit at the BEGINNING
of all those spaces. Haven't quite figured that one out yet.


Sorry, Instead of the underscore character use the "a" character instead:

a;;

Substitute "a" 200 times.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Feb 14 '06 #12
MLH
I don't know how you figured it out, but that's perfect.
It just does the job. No annoying messages are needed.
Once the 200th char is entered, user hits a brick wall.
That's message enough for most folks.

Thx, MGFoster.
Feb 15 '06 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Earthling | last post by:
Dear Access Programmers, I can't seem to figure this out. The text boxes that are used to input data via my form are unbound, I want to restrict the user to only put input that is one line. ...
1
by: Trevor Best | last post by:
When did this change? I thought is was 64K but I managed to dump 18MB in one, Access crashed when I scrolled to the bottom (out of memory error then sent report to MS). Out of interest, does anyone...
2
by: MLH | last post by:
What's the simplest way to allow a user of an A97 app to change password?
4
by: Bill Stock | last post by:
The few times in the past that I've loaded unbound data, I've tended to cheat and use temp tables (not really unbound) or use code for small datasets. I'm currently involved in a project that...
1
by: Tim::.. | last post by:
Hi... Can someone please tell me the simplest solution to create an update page for a menu I have on an asp.net website... Basiclly I have 10 menu and 10 price fields that change every day! I...
10
by: Arno R | last post by:
Hi all, I have a database that I need to use in different versions of Access. This is A97 in most places and A2k in a few other locations. (I develop in A97 and convert the db to A2k for these...
0
by: colleen1980 | last post by:
Hi: There are two textboxs in my main form. One is bound and another is unbound. There is no entry in the unbound textbox as values come into automatically after entering some information in the...
3
by: Richard | last post by:
How is the result of query placed in a unbound textbox ? Suppose CriteriaLookups has columns TableName, KeyColumn, KeyValue, DataColumn Foo,x,11,xhat Bar,z,3,xyzzy And
1
by: dpark29 | last post by:
Access 2000 - If a textbox control is bound to a hyperlink field in an Access database table, the textbox appears formatted as hyperlink and when the user right-clicks the field, the Hyperlink option...
8
by: crazyhouse | last post by:
I want to use temporary information from an unbound textbox, but i cant seem to run any code on an unbound textbox. Is this possible. I have it working with a bound "control" but cant seem to make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.