Solved

Capitalize letter after number

Posted on 2014-04-16
1
391 Views
Last Modified: 2014-04-16
I have a text box and I would like any letter after a number to be capitalized. (123a Gold St -> 123A Gold St) after a user updates the data on the form.

Any suggestions with the best way to handel this in the VBA after update event?
0
Comment
Question by:thandel
1 Comment
 
LVL 1

Accepted Solution

by:
cctanaka earned 500 total points
ID: 40005743
I suggest to create a function to capitalize. Them call this function in the update event.
Let's say the textbox name is "txtdata"

then in the update event

txtdata.text = Capital_After_Numbers(txtdata.text)

--------------------

Function Capital_After_Numbers (texto as string) as string
Dim count as integer
Dim LastCharIsNumber  as boolean


Capital_After_Numbers = ""
LastCharIsNumber = false

For count = 1 to len (texto)

    if LastCharIsNumber then
        Capital_After_Numbers = Capital_After_Numbers & UCase(Mid(texto, count, 1))
    End If

    If asc(Mid(texto, count, 1))>= 48 And asc(Mid(texto, count, 1))<= 57  then
        LastCharIsNumber = True
    else
        LastCharIsNumber = False
    End If

next count

End Function
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now