Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capitalize First letter of Field

5 views
Skip to first unread message

ma...@ix.netcom.com

unread,
Oct 28, 1995, 3:00:00 AM10/28/95
to nchr...@biddeford.com
Nathan:

I was able to get this function working. Thanks much. This will do what
I was looking for.

Just One more question. Is there a way to utilize this function in the
same field that information is being entered in?; possibly by using a
lost focus event, etc. Right now I am using (2) fields to achieve the
capitalize function. One to enter data, and the other to call this data
field and perform the "Proper" capitalize function.

What I would like to do is enter the data: i.e. john smith and have
Access convert to John Smith when tabbing to the next field.

Mark
---------------
ma...@ix.netcom.com


Bill Paine

unread,
Oct 30, 1995, 3:00:00 AM10/30/95
to

>Just One more question. Is there a way to utilize this function in the
>same field that information is being entered in?;...

>What I would like to do is enter the data: i.e. john smith and have
>Access convert to John Smith when tabbing to the next field.

put your call to 'Proper' in the "AfterUpdate" property of the field
you would like to modify.

Hope this helps,
Bill Paine

Eric Rossing

unread,
Oct 30, 1995, 3:00:00 AM10/30/95
to
ma...@ix.netcom.com wrote:
> Just One more question. Is there a way to utilize this function in the
> same field that information is being entered in?; possibly by using a
> lost focus event, etc. Right now I am using (2) fields to achieve the
> capitalize function. One to enter data, and the other to call this data
> field and perform the "Proper" capitalize function.
>
> What I would like to do is enter the data: i.e. john smith and have
> Access convert to John Smith when tabbing to the next field.

Try pasting the function into the data field's BeforeUpdate event
procedure, and replace InText with the field's control's name. This will
run the code on the field right before it saves the field.

If that doesn't work(I may be misremembering when BeforeUpdate runs, put
the code in the field's LostFocus or Exit events.

--
Eric Rossing
Intec Company, Inc.
eros...@sirus.com

Barry Westwood

unread,
Nov 1, 1995, 3:00:00 AM11/1/95
to tre...@microprism.com
Heres another solution.... with a lot less code!


baz


Function correct_case (Anyvalue As Variant) As Variant

'
' Accepts: a text value
' Purpose: converts first letter of each word to uppercase
' Returns: converted text value
'
' Note1: although this function converts most proper names correctly,
it converts
' 'McKee' to 'Mckee', 'van Buren' to 'Van Buren', 'John III' to
'John Iii'
'
' Note2: this function is best run from the "after update" property
' Ex: me![mycontrol] = correct_case(me![mycontrol])
'

Dim ptr As Integer
Dim theString As String
Dim currChar As String, prevChar As String

If IsNull(Anyvalue) Then
Exit Function
End If

theString = CStr(Anyvalue)
For ptr = 1 To Len(theString) 'Go through string char by
char.
currChar = Mid$(theString, ptr, 1) 'Get the current character.

Select Case prevChar 'If previous char is letter,
'this char should be
lowercase.
Case "A" To "Z", "a" To "z"
Mid(theString, ptr, 1) = LCase(currChar)

Case Else
Mid(theString, ptr, 1) = UCase(currChar)

End Select
prevChar = currChar
Next ptr
correct_case = CVar(theString)


End Function


Rajesh Sinha

unread,
Nov 2, 1995, 3:00:00 AM11/2/95
to ma...@ix.netcom.com
ma...@ix.netcom.com wrote:

>Just One more question. Is there a way to utilize this function in the
>same field that information is being entered in?; possibly by using a
>lost focus event, etc. Right now I am using (2) fields to achieve the
>capitalize function. One to enter data, and the other to call this data
>field and perform the "Proper" capitalize function.
>
>What I would like to do is enter the data: i.e. john smith and have
>Access convert to John Smith when tabbing to the next field.

Hi there, Mark ....

I didn't see your previous post, but I think what you may want to do here is
set the 'AfterInsert' property of the field you want to format so that it calls
the function. When data has been entered and you have left the particular
field to go to any other field, the formatting will take place. (This will
mean that you can leave the field and go to *any other* field and it will
automatically change, rather than having to go to a particular field set up to
reformat the name).

Erm, I usually try to use cunning formatting of this sort with my databases,
but awkward folk with names like Tess d'Urberville always throw a spanner in
the works!

Hope this helps,

Rajesh
======


Trevor Best

unread,
Nov 5, 1995, 3:00:00 AM11/5/95
to
ma...@ix.netcom.com wrote:
[snip]
>>>put your call to 'Proper' in the "AfterUpdate" property of the field
>>>you would like to modify.
>>
>>Ooooooh no :-O
>>Put it in the BeforeUpdate event otherwise you'll go loopy.
[snip]
>Charlie was a chemist, but Charlie is no more.
> What Charlie thought was H2O was H2SO4.

>Trevor:

>Thank you for your correction to the question. I really got a chuckle
>about Charlie the chemist.

Actually I goofed up, Access won't allow you to change the field in
BeforeUpdate(), it complains "Can't change field while it's being
validated". I did a similar thing in AfterUpdate and it was OK, the
AfterUpdate only seems to execute if you update the field manually so
setting it to another value in code doesn't make it recursivly call
AfterUpdate() like I thought it would.

That wasn't the first time I goofed up either (probably won't be the
last:), I made the same mistake as Charlie although the outcome was
more fortunate for me than it was for poor Charlie, I estimate that I
drank well over a gallon of water (the proper H20) afterwards from the
sink in the corner of the lab. I make a point of drinking only from
known sources since then (I was rather young hyperactive schoolboy
then) and apart from this funny looking mark on my elbow (the result
of horsing around with hydrochloric acid) have not had any any acid
accidents since. (I've not included the caustic soda incident where my
lips ballooned as it's an alkali and not an acid:)

(who said programmers were boring?)


\|||/
/ \
C o o D
-----------------ooO--u--Ooo-------------------------------
Do students of Zen Buddhism do Om-work?

tre...@microprism.com - Microprism (UK) Limited


0 new messages