I'm using a data input form to add records to my table. I'm collecting
address information and want the first letter of each word to be capital in
the address field. I searched this site and found some code the would
accomplish this however when I use it, I get errors. I'm wondering if it is
because the address contain numberic values, then a street name followed by
Street, Lane, Blvd. etc. Can you take a look at this and see why it is
generating an error..
Private Sub CHAPADD_AfterUpdate()
If StrComp(Me!txtCHAPADD, LCase(Me!Text), 0) = 0 Then
Me!txtCHAPADD = StrConv(Me!txtCHAPADD, vbProperCase)
End If
End Sub
|
|
0
|
|
|
|
Reply
|
Utf
|
12/16/2007 8:30:00 PM |
|
Hi
Is there are reason why you're not just using
Private Sub CHAPADD_AfterUpdate()
Me.CHAPADD = StrConv(Me.CHAPADD, 3)
End Sub
--
Wayne
Manchester, England.
"SITCFanTN" wrote:
> I'm using a data input form to add records to my table. I'm collecting
> address information and want the first letter of each word to be capital in
> the address field. I searched this site and found some code the would
> accomplish this however when I use it, I get errors. I'm wondering if it is
> because the address contain numberic values, then a street name followed by
> Street, Lane, Blvd. etc. Can you take a look at this and see why it is
> generating an error..
>
> Private Sub CHAPADD_AfterUpdate()
> If StrComp(Me!txtCHAPADD, LCase(Me!Text), 0) = 0 Then
> Me!txtCHAPADD = StrConv(Me!txtCHAPADD, vbProperCase)
> End If
> End Sub
>
|
|
1
|
|
|
|
Reply
|
Utf
|
12/16/2007 8:44:40 PM
|
|
On Sun, 16 Dec 2007 12:30:00 -0800, SITCFanTN
<SITCFanTN@discussions.microsoft.com> wrote:
> I searched this site and found some code the would
>accomplish this however when I use it, I get errors.
What errors? What data input triggers the error?
John W. Vinson [MVP]
|
|
1
|
|
|
|
Reply
|
John
|
12/16/2007 8:58:06 PM
|
|
On Sun, 16 Dec 2007 12:30:00 -0800, SITCFanTN wrote:
> I'm using a data input form to add records to my table. I'm collecting
> address information and want the first letter of each word to be capital in
> the address field. I searched this site and found some code the would
> accomplish this however when I use it, I get errors. I'm wondering if it is
> because the address contain numberic values, then a street name followed by
> Street, Lane, Blvd. etc. Can you take a look at this and see why it is
> generating an error..
>
> Private Sub CHAPADD_AfterUpdate()
> If StrComp(Me!txtCHAPADD, LCase(Me!Text), 0) = 0 Then
> Me!txtCHAPADD = StrConv(Me!txtCHAPADD, vbProperCase)
> End If
> End Sub
If you get 'errors' it would be nice to know what errors.
This should be all you need, using VBA:
Private Sub CHAPADD_AfterUpdate()
Me!txtCHAPADD = StrConv(Me!txtCHAPADD, vbProperCase)
End Sub
Numbers and symbols are not affected.
Note: While this will capitalize the first letter of each word, some
words ought not be capitalized, i.e. van Houten, van Beethoven ,
Avenue of the Americas, etc., and it will improperly remove capitals
from words that ought to have more than one capital, i.e. O'Brien,
McDonald, Smith-Jones, etc.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
|
|
0
|
|
|
|
Reply
|
fredg
|
12/16/2007 9:00:01 PM
|
|
|
3 Replies
898 Views
(page loaded in 0.085 seconds)
|