By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Create a script to change first three words of text to uppercase

P: 4
I want to use an AfterUpdate Event to change the first three words in an Access text field to uppercase. I need suggestions on the correct syntax for the script. thank you.
Nov 25 '13 #1
Share this Question
Share on Google+
4 Replies

Seth Schrock
Expert 2.5K+
P: 2,941
I believe this is what you want.
Expand|Select|Wrap|Line Numbers
  1. Dim strText As String
  2. Dim intLoc As Integer
  4. strText = "One Two Three Four Five Six"
  5. intLoc = InStr(InStr(InStr(1, strText, " ") + 1, strText, " ") + 1, strText, " ")
  6. strText = UCase(Left(strText, intLoc)) & Mid(strText, intLoc + 1)
  7. Debug.Print strText
This returns "ONE TWO THREE Four Five Six". All you would have to do is make line 4 be
Expand|Select|Wrap|Line Numbers
  1. strText = Me.ControlName
and then add a line at the end
Expand|Select|Wrap|Line Numbers
  1. Me.ControlName = strText
and you would have it. Just replace ControlName with the name of your control.
Nov 25 '13 #2

Expert Mod 5K+
P: 5,397
Sounds like a homework problem?

Besides, I'd use the split function, ucase the first three array elements and then rebuild the string.
Nov 25 '13 #3

P: 4
Not homework, its a work-related database. thank you!
Nov 25 '13 #4

P: 4
@Seth Schrock
Nov 25 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.