How do you capitalize first and last name in access?

D

Danny Lesandrini

This sort of depends on where you want to do it. Do you want
to fix the actual data in the table or just change the display on
a form or report?

This might work for you: StrConv([Field], vbProperCase)
?StrConv("danny",vbProperCase)
Danny

?StrConv("danny j",vbProperCase)
Danny J

?StrConv("danny j lesandrini",vbProperCase)
Danny J Lesandrini

If you want to fix the data, you'd run an update query, like this ...

UPDATE tblContacts SET [FirstName] = StrConv([FirstName ], vbProperCase)

If it's on the report or form, you can set the control source to this ...
=StrConv([FirstName], vbProperCase)

Perhaps you can even set a format value for this, but I've never taken that tack.
 
F

fredg

I need to capitalize the first and last name in a field, how do I do this?

Do this where?
On a form?
On the Form's control's AfterUpdate event code:
Me![ControlName] = StrConv([ControlName],3)

In a query?
NewColumn:StrConv([FieldName],3)

Note: this will incorrectly capitalize some words which contain more
than one capital, i.e. O'Brien, MacDonald, IBM, Jones-Smith, ABC,
etc., and incorrectly capitalize some words that should not have any
capitals, or whose capitalization depends upon usage, such as e. e.
cummings, abc, van den Steen.
Then some names can be capitalized in more than one manner, depending
upon personal preference, i.e. O'Connor and O'connor, McDaniels and
Mcdaniels, etc. are both correct.

You can create a table of exceptions and have the code use DLookUp
with a message if one of the exception words is found.
 
P

Pupdawg

In the form. In the AfterUpdate event code, do I just plug this string in?

fredg said:
I need to capitalize the first and last name in a field, how do I do this?

Do this where?
On a form?
On the Form's control's AfterUpdate event code:
Me![ControlName] = StrConv([ControlName],3)

In a query?
NewColumn:StrConv([FieldName],3)

Note: this will incorrectly capitalize some words which contain more
than one capital, i.e. O'Brien, MacDonald, IBM, Jones-Smith, ABC,
etc., and incorrectly capitalize some words that should not have any
capitals, or whose capitalization depends upon usage, such as e. e.
cummings, abc, van den Steen.
Then some names can be capitalized in more than one manner, depending
upon personal preference, i.e. O'Connor and O'connor, McDaniels and
Mcdaniels, etc. are both correct.

You can create a table of exceptions and have the code use DLookUp
with a message if one of the exception words is found.
 
F

fredg

In the form. In the AfterUpdate event code, do I just plug this string in?

fredg said:
I need to capitalize the first and last name in a field, how do I do this?

Do this where?
On a form?
On the Form's control's AfterUpdate event code:
Me![ControlName] = StrConv([ControlName],3)

In a query?
NewColumn:StrConv([FieldName],3)

Note: this will incorrectly capitalize some words which contain more
than one capital, i.e. O'Brien, MacDonald, IBM, Jones-Smith, ABC,
etc., and incorrectly capitalize some words that should not have any
capitals, or whose capitalization depends upon usage, such as e. e.
cummings, abc, van den Steen.
Then some names can be capitalized in more than one manner, depending
upon personal preference, i.e. O'Connor and O'connor, McDaniels and
Mcdaniels, etc. are both correct.

You can create a table of exceptions and have the code use DLookUp
with a message if one of the exception words is found.

In the AfterUpdate event of the Control.
Change [ControlName] to whatever the actual name of the control is.
 
J

John W. Vinson

On Thu, 29 Jan 2009 14:23:01 -0800, Pupdawg

Open the form in design view. Select the control; view its Properties; in the
Events tab select the AfterUpdate event. Click the ... line to the right of
the box, and choose "Code Builder". Access will give you

Private Sub LastName_AfterUpdate()

End Sub

Just edit fred's line in between these.
In the form. In the AfterUpdate event code, do I just plug this string in?

fredg said:
I need to capitalize the first and last name in a field, how do I do this?

Do this where?
On a form?
On the Form's control's AfterUpdate event code:
Me![ControlName] = StrConv([ControlName],3)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top