473,785 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2472
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_Cha nge()
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_Bef oreUpdate(Cance l As Integer)

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

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

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

iQA/AwUBQ/DGP4echKqOuFEgE QI2/ACg1OrLoU4dmt08 QDGLHaI8hLoDu/oAoKP2
e/mwmh05UNq1fZERe vGI9g3Z
=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********@Fort uneJames.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:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)
Feb 13 '06 #6
Lots of good solutions - here's my favorite:
Private Sub Notes_memo_Afte rUpdate()
Me.Notes_memo = Left(Me.Notes_m emo, 200)
End Sub

Private Sub Notes_memo_KeyP ress(KeyAscii As Integer)
If Len(Me.Notes_me mo.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**@NorthStat e.net> wrote in message
news:8q******** *************** *********@4ax.c om...
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********@Fort uneJames.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_Cha nge()

' 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

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

Similar topics

2
1726
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. Eg.
1
1965
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 what a reasonable limit is? i.e. how much text can be dumped and scrolled without crashing. -- Pretentious? Moi?
2
2418
by: MLH | last post by:
What's the simplest way to allow a user of an A97 app to change password?
4
1932
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 has numerous tables in the 200 column range, with several thousand rows of data. A consulting review prior to my involvement stressed the wasted space and database speed as the major impetus for normalization. Although the db actually works fairly...
1
1141
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 want to stor the information in an SQL Database and have created a very simple table with with the following fields: menuID
10
1678
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 other locations) FYI: I am using A97 as backend for both versions. No problem. After conversion A97 > A2k everything (seems to) work(s) just fine, except for one thing I only discovered today. Using an unbound form to collect data that is used in...
0
3012
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 subform. My question is how to i pass values from unbound textbox to bound textbox every time when the value change in unbound textbox i need to change the value in the bound textbox. When the form load there is already value in the bound textbox...
3
11278
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
15196
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 is available on the resulting popup Shortcut Menu form. I am developing a form that uses unbound textboxes, and I need to include a textbox that will contain a hyperlink. How do I get an unbound textbox to act like a textbox that is bound to a...
8
3871
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 it work with an unbound control.
0
10357
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10101
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.