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? 9 1544
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))
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?
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
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.
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.
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?
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.
"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: >?<??????????????????????????
That doesn't help, other than it fills in the first character in
uppercase directly. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Heather Stovold |
last post by:
Hi all...
I am looking at writing a little program for my own use, and probably for a
bunch of other people too, and I am trying to decide what would be the best
language to use.
I am a...
|
by: Ksenia Marasanova |
last post by:
Hi,
I have a little problem with encoding. Was hoping maybe anyone can
help me to solve it.
There is some amount of data in a database (PG) that must be inserted
into Excel sheet and emailed....
|
by: John Baker |
last post by:
Hi:
At the outset let me admit that I screwed up!
I have built a rather elaborate set of forms and sub forms starting with a client table,
and going down to PO and Line item. This works very...
|
by: AA Arens |
last post by:
When I fill in the data in a field, capital characters are changed in
lower case. How to solve it?
Like:
Company name: SONY
becomes after Enter or Tab:
Company name: Sony
|
by: Titanus |
last post by:
Hello all,
I am running MS on a Dell PC and I want to get started writing C++
code. Only thing I can find about how to get started is to find MS SQL
Server. Okay, so once I find that, how do I...
|
by: kev |
last post by:
Hi all,
i would like to know how can we ensure that a user fill in each field
in a form?
How do we create a warning message of a sort" Please fill in the
details"
I hope to get a detailed...
|
by: martin DH |
last post by:
Hello,
In a report, for every record, I would like a checkbox to appear checked if a certain field contains any value.
The field is Client_comments. (memo field)
I added a checkbox called...
|
by: ADezii |
last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
|
by: smk17 |
last post by:
I've spent the last few minutes searching for this question and I
found an answer, but it wasn't quite what the client wanted.
I have a simple online form where the user needs to fill out five...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |