View Full Version : need to capitalize a field


fletch
12-09-2002, 01:00 PM
I have a database with two fields for emailing. Firstname and Email.

I want to run a query to capitalize just the first character of the Firstname field.

I figured out how to change the field to lowercase but that's it.

Now I need the first character changed to upper case.

I only know how to do queries. I often see samples in these forums of VB code but I don't know where or how to use it.

I did find the Proper function but don't know how to use it either.

Help?

Jim

Peter D
12-09-2002, 01:11 PM
This link should help:

http://www.mvps.org/access/strings/str0005.htm

... a more advanced example is here:

http://www.mvps.org/access/strings/str0008.htm

Hope this helps,

fletch
12-09-2002, 01:16 PM
As I stated, I don't know how or where to put that type of code.

I've only used the query expression builder up to this point.

If those things work, I unfortunately need specific instructions on how to use that code.

Jim

Jon K
12-09-2002, 11:15 PM
Try this in a new column in the query grid (using the correct table name):-

Field: FirstName: UCase(Left([TableName].[FirstName],1)) & LCase(Mid([TableName].[FirstName],2))

Show: check

fletch
12-10-2002, 04:13 AM
thank you...perfect.

Now, I discovered there's some middle initials in the first name, is there a way to strip everything from the right away? Up to the first blank?

Jim

Jon K
12-10-2002, 04:53 AM
Try this:-

FirstName: UCase(Left([TableName].[FirstName],1)) & LCase(Mid([TableName].[FirstName],2,IIf(InStr([TableName].[FirstName]," ")>0,InStr([TableName].[FirstName]," ")-2,Len([TableName].[FirstName]))))

fletch
12-10-2002, 05:02 AM
thank you. Again...perfect. Went from a 3 hour job to a 3 minute one.

Much appreciated.

Jim

Mile-O
12-10-2002, 08:34 AM
Also, if you have to just convert just the first letter to upper case then proper case might be what you are after.


strConvertMe = StrConv(strConvertMe,vbProperCase)