A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Input mask help



 
 
Thread Tools Display Modes
  #1  
Old November 30th, 2008, 12:01 AM posted to microsoft.public.access.tablesdbdesign
Tom
external usenet poster
 
Posts: 1,359
Default Input mask help

si am using access 2003 and I have a field in the table called city
i want to create an input mask to automatically capitalize the first letter
of city names even if they have two parts such as New Cambridge or
North Canton
I know that if i use the input mask as follows
L????????? that I will get the first word capitalized and the following letter in lower case which is what I want , but how do I indicate the same for a second part of the city name field if one exists ???? any suggestions are greatly appreciated

Thanks in advance
  #2  
Old November 30th, 2008, 01:07 AM posted to microsoft.public.access.tablesdbdesign
Ken Snell \(MVP\)
external usenet poster
 
Posts: 2,506
Default Input mask help

Not doable via input mask if you have a varying length for the first city
word.

You can do it in a form by using the AfterUpdate event of the textbox to
capitalize the first letter of each city word; but it would capitalize the
first letter of EVERY city word (so you'd get London On Thames instead of
London on Thames).

Are you using a form for entering the data?

--

Ken Snell
MS ACCESS MVP
http://www.accessmvp.com/KDSnell/


"Tom" wrote in message
...
si am using access 2003 and I have a field in the table called city
i want to create an input mask to automatically capitalize the first
letter
of city names even if they have two parts such as New Cambridge or
North Canton
I know that if i use the input mask as follows
L????????? that I will get the first word capitalized and the following
letter in lower case which is what I want , but how do I indicate the same
for a second part of the city name field if one exists ???? any
suggestions are greatly appreciated

Thanks in advance



  #3  
Old November 30th, 2008, 01:39 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Input mask help

On Sat, 29 Nov 2008 16:01:01 -0800, Tom wrote:

si am using access 2003 and I have a field in the table called city
i want to create an input mask to automatically capitalize the first letter
of city names even if they have two parts such as New Cambridge or
North Canton
I know that if i use the input mask as follows
L????????? that I will get the first word capitalized and the following letter in lower case which is what I want , but how do I indicate the same for a second part of the city name field if one exists ???? any suggestions are greatly appreciated

Thanks in advance


Input masks simply do not have the power to do this. You'll need to use the
builtin StrConv() function to do this. Are you talking about changing values
in the table already (e.g. the table now contains "new cambridge" or "NEW
CAMBRIDGE") and you want to fix it, or do you want this to change what the
user types as they enter it?

In the former case, run an update query updating City to

StrConv([City], 3)

3 is the code for Proper Case (Every Word Capitalized); 1 converts to lower
case, 2 to UPPER CASE, 4 and higher are for Asian languages - see the online
help.

If you want the data to be converted on the fly as the user enter's data, then
you must (no option) use a Form to enter the data - tables have no usable
events. Use the textbox's AfterUpdate event:

Private Sub City_AfterUpdate()
Me!City = StrConv(Me!City, vbProperCase)
End Sub

vbProperCase is just a constant equal to 3 - you can use the constant in VBA
code but not in a query.
--

John W. Vinson [MVP]
  #4  
Old November 30th, 2008, 05:01 PM posted to microsoft.public.access.tablesdbdesign
Tom
external usenet poster
 
Posts: 1,359
Default Input mask help

yes I am using a form to enter the data . I have used the after update event
for other things but never to do as you suggested. Could you give me an
example of the code to make that work? I really appreciate all your help

Tom

"Ken Snell (MVP)" wrote:

Not doable via input mask if you have a varying length for the first city
word.

You can do it in a form by using the AfterUpdate event of the textbox to
capitalize the first letter of each city word; but it would capitalize the
first letter of EVERY city word (so you'd get London On Thames instead of
London on Thames).

Are you using a form for entering the data?

--

Ken Snell
MS ACCESS MVP
http://www.accessmvp.com/KDSnell/


"Tom" wrote in message
...
si am using access 2003 and I have a field in the table called city
i want to create an input mask to automatically capitalize the first
letter
of city names even if they have two parts such as New Cambridge or
North Canton
I know that if i use the input mask as follows
L????????? that I will get the first word capitalized and the following
letter in lower case which is what I want , but how do I indicate the same
for a second part of the city name field if one exists ???? any
suggestions are greatly appreciated

Thanks in advance




  #5  
Old November 30th, 2008, 05:04 PM posted to microsoft.public.access.tablesdbdesign
Tom
external usenet poster
 
Posts: 1,359
Default Input mask help

Thanks John That did it!1 You really helped me out because I was trying to do
it as the used entered the information originally
Thanks a million
tom

"John W. Vinson" wrote:

On Sat, 29 Nov 2008 16:01:01 -0800, Tom wrote:

si am using access 2003 and I have a field in the table called city
i want to create an input mask to automatically capitalize the first letter
of city names even if they have two parts such as New Cambridge or
North Canton
I know that if i use the input mask as follows
L????????? that I will get the first word capitalized and the following letter in lower case which is what I want , but how do I indicate the same for a second part of the city name field if one exists ???? any suggestions are greatly appreciated

Thanks in advance


Input masks simply do not have the power to do this. You'll need to use the
builtin StrConv() function to do this. Are you talking about changing values
in the table already (e.g. the table now contains "new cambridge" or "NEW
CAMBRIDGE") and you want to fix it, or do you want this to change what the
user types as they enter it?

In the former case, run an update query updating City to

StrConv([City], 3)

3 is the code for Proper Case (Every Word Capitalized); 1 converts to lower
case, 2 to UPPER CASE, 4 and higher are for Asian languages - see the online
help.

If you want the data to be converted on the fly as the user enter's data, then
you must (no option) use a Form to enter the data - tables have no usable
events. Use the textbox's AfterUpdate event:

Private Sub City_AfterUpdate()
Me!City = StrConv(Me!City, vbProperCase)
End Sub

vbProperCase is just a constant equal to 3 - you can use the constant in VBA
code but not in a query.
--

John W. Vinson [MVP]

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:43 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.