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

How to have filled data in field started with CAPITAL?

P: n/a
I want the filled data in a field starts always with a Capital
character.

Private Sub myfield_AfterUpdate()
Me!myfield= UCase$(Left$(Me!myfield, 1))
End Sub

caused the cursor to be moved to the left / last character.

But, it caused also that only 1 character is filled after update:
Like:
keyboard > K
and not
keyboard > Keyboard

How to solve it?

Nov 13 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
well, left$(Me!MyField,1) returns only one character. Where's the rest
of the string?

You need something like

ucase$(LEFT$(Me!MyField,1)) &
LCase$(right$(Me!MyField,Len$(Me!MyField)-1))

Nov 13 '05 #2

P: n/a
If you would like the keystrokes to be converted to upper case as the user
types them:

1 Set the control's On Key Press property to:
[Event Procedure]

2. Click the Build button (...) beside this.
Access opens the code window.

3. Between the "Private Sub..." and "End Sub" lines, enter:

If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
End If

BTW, do NOT simply use > in the Format property. That makes Access to
display the value in upper case, but does not store the values in upper
case.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"AA Arens" <ba***********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
I want the filled data in a field starts always with a Capital
character.

Private Sub myfield_AfterUpdate()
Me!myfield= UCase$(Left$(Me!myfield, 1))
End Sub

caused the cursor to be moved to the left / last character.

But, it caused also that only 1 character is filled after update:
Like:
keyboard > K
and not
keyboard > Keyboard

How to solve it?

Nov 13 '05 #3

P: n/a
On 21 Jul 2005 19:20:56 -0700, pi********@hotmail.com wrote:
well, left$(Me!MyField,1) returns only one character. Where's the rest
of the string?

You need something like

ucase$(LEFT$(Me!MyField,1)) &
LCase$(right$(Me!MyField,Len$(Me!MyField)-1))


or..

UCase$(Left$(Me!MyField,1)) & Mid$(Me!MyField,2)

Of course, that will barf on nulls, so this might be the easy work-around...

UCase(Left(Me!MyField,1)) + Mid(Me!MyField,2)

Or for reusability
Public Function Capitalized(Value As Variant) As Variant
Capitalized = UCase(Left(Value,1)) + Mid(Value,2)
End Function

Public Sub Capitalize(ByRef Value As Variant)

If IsObject(Value) Then
Dim obj As Object: Set obj = Value
obj = Capitalized(Value)
Else
Value = Capitalized(Value)
End If

End Sub

....

Capitalize Me!MyField
Nov 13 '05 #4

P: n/a
On Fri, 22 Jul 2005 10:44:09 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
If you would like the keystrokes to be converted to upper case as the user
types them:

1 Set the control's On Key Press property to:
[Event Procedure]

2. Click the Build button (...) beside this.
Access opens the code window.

3. Between the "Private Sub..." and "End Sub" lines, enter:

If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
End If

BTW, do NOT simply use > in the Format property. That makes Access to
display the value in upper case, but does not store the values in upper
case.


That fails with a paste from the clipboard since the character is never
actually typed. One way to mostly plug the hole (that I find good enough) is
to do both the keypress handler and After Update. That way, if there's any
case where it's not done in real-time, it still gets done soon enough.
Nov 13 '05 #5

P: n/a
Quite right, Steve. It needs the AfterUpdate code as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Steve Jorgensen" <no****@nospam.nospam> wrote in message
news:vv********************************@4ax.com...
On Fri, 22 Jul 2005 10:44:09 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
If you would like the keystrokes to be converted to upper case as the user
types them:

1 Set the control's On Key Press property to:
[Event Procedure]

2. Click the Build button (...) beside this.
Access opens the code window.

3. Between the "Private Sub..." and "End Sub" lines, enter:

If KeyAscii >= 97 And KeyAscii <= 122 Then
KeyAscii = KeyAscii - 32
End If

BTW, do NOT simply use > in the Format property. That makes Access to
display the value in upper case, but does not store the values in upper
case.


That fails with a paste from the clipboard since the character is never
actually typed. One way to mostly plug the hole (that I find good enough)
is
to do both the keypress handler and After Update. That way, if there's
any
case where it's not done in real-time, it still gets done soon enough.

Nov 13 '05 #6

P: n/a
Check out StrConv(string, conversion) in Help.

Ron
AA Arens wrote:
I want the filled data in a field starts always with a Capital
character.

Private Sub myfield_AfterUpdate()
Me!myfield= UCase$(Left$(Me!myfield, 1))
End Sub

caused the cursor to be moved to the left / last character.

But, it caused also that only 1 character is filled after update:
Like:
keyboard > K
and not
keyboard > Keyboard

How to solve it?


Nov 13 '05 #7

P: n/a
I followed up of of the ideas:

Me!City = UCase$(Left$(Me!City, 1)) + Mid$(Me!City, 2)
UCase (Left(Me!City, 1)) + Mid(Me!City, 2)

It works (words become capitalized for 1st character) and also when I
do not fill anything by ignoring the field by TAB button, no error.

I only get an error when I fill someting in the field and then empty it
with the backspace.

Nov 13 '05 #8

P: n/a
"AA Arens" <ba***********@gmail.com> wrote in news:1122109287.488418.107090
@g49g2000cwa.googlegroups.com:
I followed up of of the ideas:

Me!City = UCase$(Left$(Me!City, 1)) + Mid$(Me!City, 2)
UCase (Left(Me!City, 1)) + Mid(Me!City, 2)

It works (words become capitalized for 1st character) and also when I
do not fill anything by ignoring the field by TAB button, no error.

I only get an error when I fill someting in the field and then empty it
with the backspace.


What if you use an inputmask like: >?<??????????????????????????

Nov 13 '05 #9

P: n/a
That doesn't help, other than it fills in the first character in
uppercase directly.

Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.