473,811 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A97 How to force uppercase alpha chars in a textbox on a form?

MLH
I have a textbox on a form into which an alpha-numeric string
of data is entered. I wish to force the casual user, who would
sometimes use upper case, sometimes not and sometimes MIX
the case - yes, believe it - to use UPPER case only.

I tried running UCASE on the string entered during the textbox's
BeforeUpdate event code. That did nothing but return some error
saying I couldn't do it there - some kind-a-race condition, I dunno -
can't change while updating - whatever!

Can I somehow use textbox's inputmask property to allow only
uppercase alpha-numeric strings 2B entered?
Nov 13 '05 #1
8 31840
MLH
And, if I can not use inputmask to filter out lower-case alpha
chars, can I force a conversion of what's being entered keystroke-
by-keystroke in a keydown event procedure?
Nov 13 '05 #2
Use UCase() in the *AfterUpdate* event of the text box to convert the case.

You can place a > in the Format event of the text box to force the display
(but not stored value) to upper case. Don't do this with memo fields: it
truncates to 255 characters.

It is also possible to use the KeyPress event to alter the KeyAscii to the
upper case version of the entry. You still need the AfterUpdate event as
well, in case the user pastes text in.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthStat e.net> wrote in message
news:a1******** *************** *********@4ax.c om...
I have a textbox on a form into which an alpha-numeric string
of data is entered. I wish to force the casual user, who would
sometimes use upper case, sometimes not and sometimes MIX
the case - yes, believe it - to use UPPER case only.

I tried running UCASE on the string entered during the textbox's
BeforeUpdate event code. That did nothing but return some error
saying I couldn't do it there - some kind-a-race condition, I dunno -
can't change while updating - whatever!

Can I somehow use textbox's inputmask property to allow only
uppercase alpha-numeric strings 2B entered?

Nov 13 '05 #3
MLH
Thanks, Allen. Do you recommend I use something like
Me!MyField.Text = UCase(Me!MyFiel d.Text)
or can I just use
Me!MyField = UCase(Me!MyFiel d) ? I tried the former
in the OnLostFocus event code. But, it seemed to generate another
Update event (unwanted).

xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxx

On Fri, 12 Aug 2005 11:02:47 +0800, "Allen Browne"
<Al*********@Se eSig.Invalid> wrote:
Use UCase() in the *AfterUpdate* event of the text box to convert the case.

You can place a > in the Format event of the text box to force the display
(but not stored value) to upper case. Don't do this with memo fields: it
truncates to 255 characters.

It is also possible to use the KeyPress event to alter the KeyAscii to the
upper case version of the entry. You still need the AfterUpdate event as
well, in case the user pastes text in.


Nov 13 '05 #4
Don't bother with the Text bit.

You're alergic to the AfterUpdate event? It's the one that runs after a
change, and if there was no change you don't need it.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"MLH" <CR**@NorthStat e.net> wrote in message
news:8p******** *************** *********@4ax.c om...
Thanks, Allen. Do you recommend I use something like
Me!MyField.Text = UCase(Me!MyFiel d.Text)
or can I just use
Me!MyField = UCase(Me!MyFiel d) ? I tried the former
in the OnLostFocus event code. But, it seemed to generate another
Update event (unwanted).

xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxxxxxxxxx xxxxxxxx

On Fri, 12 Aug 2005 11:02:47 +0800, "Allen Browne"
<Al*********@Se eSig.Invalid> wrote:
Use UCase() in the *AfterUpdate* event of the text box to convert the
case.

You can place a > in the Format event of the text box to force the display
(but not stored value) to upper case. Don't do this with memo fields: it
truncates to 255 characters.

It is also possible to use the KeyPress event to alter the KeyAscii to the
upper case version of the entry. You still need the AfterUpdate event as
well, in case the user pastes text in.

Nov 13 '05 #5
MLH
>Don't bother with the Text bit.
10:4

You're alergic to the AfterUpdate event? It's the one that runs after a
change, and if there was no change you don't need it.

Ha! You got me on that one. Yeah, I had so much going on in the
afterupdate event code, I didn't wanna throw more in the mix, if I
could help it. But, I'll try it. I'm sure it'll work. Thx.
Nov 13 '05 #6
Use the keypress event

Private Sub Text0_KeyPress( KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(K eyAscii)))
End Sub

this will then convert the user input to upper case as they input it.
--
Terry Kreft
MVP Microsoft Access
"MLH" <CR**@NorthStat e.net> wrote in message
news:a1******** *************** *********@4ax.c om...
I have a textbox on a form into which an alpha-numeric string
of data is entered. I wish to force the casual user, who would
sometimes use upper case, sometimes not and sometimes MIX
the case - yes, believe it - to use UPPER case only.

I tried running UCASE on the string entered during the textbox's
BeforeUpdate event code. That did nothing but return some error
saying I couldn't do it there - some kind-a-race condition, I dunno -
can't change while updating - whatever!

Can I somehow use textbox's inputmask property to allow only
uppercase alpha-numeric strings 2B entered?

Nov 13 '05 #7
MLH <CR**@NorthStat e.net> wrote in
news:8p******** *************** *********@4ax.c om:
Do you recommend I use something like
Me!MyField.Text = UCase(Me!MyFiel d.Text)
or can I just use
Me!MyField = UCase(Me!MyFiel d) ? I tried the former
in the OnLostFocus event code. But, it seemed to generate another
Update event (unwanted).


Well, you either need to test for IsNull() and not do it, or
concatenate the field with a zero-length string, or this will error
out any time the field is Null.

Either:

Me!MyField = UCase(Me!MyFiel d & vbNullString)

Or:

If Not Isnull(Me!MyFie ld) Then
Me!MyField = UCase(Me!MyFiel d)
End If

In my code, most often I want to do nothing at all in the
AfterUpdate event when the value has been deleted, so I just exit
the sub, rather than repeatedly testing:

If Isnull(Me!MyFie ld) Then Exit Sub
[whatever you'd do if it's not null]

But I can conceive of things that you might want to do in
AfterUpdate if a field is Null, so that isn't always the case.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8
MLH
This sounds good. I'll give it a shot.
Use the keypress event

Private Sub Text0_KeyPress( KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(K eyAscii)))
End Sub

this will then convert the user input to upper case as they input it.


Nov 13 '05 #9

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

Similar topics

3
3809
by: Fredrik Kronander | last post by:
Hi, I have an application that let's the user enter text into a textbox and this data is collected on the server and stored in a database. The page is multilingual and sets Response.Charset to the appropiate for the language, for example gb2312 for chinese etc. This made all texts on the page show up alright. However, I did not change the codepage of the page so ASP encoded the post data sent to the server and I have got really ugly...
2
7057
by: Richard MSL | last post by:
How do you make a ComboBox force casing to uppercase? With a TextBox, I do this: TextBox txtName; this.txtName.CharacterCasing = CharacterCasing.Upper; And it makes whatever the user types appear in upper case, which is what I want. But with a ComboBox, if I do this: ComboBox TCombo; this.TCombo.CharacterCasing = CharacterCasing.Upper;
2
1923
by: Andy Johns | last post by:
I've seen plenty of examples of file uploads in ASP.NET when the only form element is the file input type, but I've not seen a practical example of a file upload routine running alongside other form elements, e.g. a text box for a description for example. If the form is being posted in multipart format then the text coming through will need to be converted first, won't it? The other issue is that if the form is posted, and the...
4
3214
by: Tina | last post by:
The web textbox doesn't have a CharacterCasing property as does the forms textbox. Any way cause characters typed in to be Upper case? Thanks, T
7
4669
by: OHM | last post by:
Hi Guys, I wouldnt normally ask for help on this but Im really strapped for time. Does anyone know how I can force characters in a DataGrid cell to uppercase as they are typed. Cheers - OHM
1
1535
by: Randy Fraser | last post by:
Could someone tell me how I can force uppercase characters in a TextBox column in a datagrid? Thanks Randy
7
8705
by: DazedAndConfused | last post by:
Curently I manualy code keypress edits. i.e. allow only 3 digits before decimal and two digits after decimal in .NET. Is there an easy solution to mask text boxes? The MSMASK32.OCX from vb6 does not seem to be appropriate for a desktop application with textboxes not bound to a dataset, am I wrong? -- How time fly's when you don't know what you are doing!
3
3678
by: =?Utf-8?B?Sm9zZXBo?= | last post by:
Hi all, I'd like to know how to force uppercase characters in an ASP.Net web form text field. Thanks
1
1968
by: ismailc | last post by:
Hi, I need help please. I have a textbox with char length 30 & a tooltip providing user information on how the value should look like. The value should be in the following order of: Test1 Test2 Test3 but the user's keep on getting it wrong: Test1 Test3 Test2 all kinds of order even though they have been educated via mail & tooltip. In the past I had 3 different text boxes that adds up to one and was cancelled as the users got...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10408
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
9211
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
7673
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
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5561
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...
1
4346
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
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3026
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.