Entering all data in UpperCase

G

Guest

I know that there are various ways to convert data entered in forms to Upper
Case
via code behind each form or control or via an input mask.

I'm wondering if any one knows a way to do this by writing a global function
that checks a preferences table and sets all data entry to "upperCase" when
the database starts without a need to add code to every form.

My database is huge, 635 forms and hundreds of linked tables, and I am
concerned about the maintenance involved if I add code to each form.

Any ideas?
 
M

Mark

Perhaps there's some way to check the state of the Caps Lock key on the
keyboard. Or maybe you could have a special form open when the database
starts, which asks the user to type their name or something. When they type
the first character (textbox KeyDown or KeyPress or whatever), you can check
if it's a capital letter by looking at the ascii code, then tell them to
turn on the caps lock if they need to.
 
J

John Vinson

I'm wondering if any one knows a way to do this by writing a global function
that checks a preferences table and sets all data entry to "upperCase" when
the database starts without a need to add code to every form.

I'm afraid not.

I'd be very leery of such a capability in any case. All caps is HARD
TO READ and is inappropriate for text such as names, not to mention
narrative text. Product codes and the like would need to be uppercased
but I'd be surprised if *everything* needs to be!

I'd go with the simplest approach, given the scale of the problem; one
possibly heretical suggestion would be to leave the data in whatever
case it was entered, and use the > input mask to *display* it in upper
case.

John W. Vinson[MVP]
 
G

Guest

I agree that using all uppercase is a terrible way to enter and view data.
However, this was a requirement from my client and was written as a condition
of purchase in the contract. They actually want the data to be stored in
uppercase to be consistant with their older legacy data.

That is why that I want it to be a configurable option that can be turned
off or on.

With 625 forms, you can imagine how many input masks I would need to create.
I have opted to write code in each form's OnKeypress event to handle this,
but even that is pretty extensive and difficult to maintain.

An associate of mine who has written some of our VB 6.0 products, indicated
that he could do this in VB on startup by coding to a different event
handler. I'm not sure what that means, but he wondered if this could be done
in Access.
 
J

John Vinson

They actually want the data to be stored in
uppercase to be consistant with their older legacy data.

The OnKey event is probably your best bet. You could use VBA to loop
through the AllForms collection and define the event in each one,
using a one-line call to a single module.

Is your client aware that Access searches are *not* case sensitive, so
there is no *compelling* need to have the cases of new and legacy data
match?

John W. Vinson[MVP]
 
G

Guest

You make a good point with regard to the queries. This client is a law
enforcement agency. There data is transferred to various goverment agencies.
There may be a data standard that they are trying to maintain for other
systems. I was not directly involved with the client so I'm not sure what
the reason is. It may be as simple as the fact that the officers can't type
and they don't want to have to use the shift key :). What ever the reason
is, I have been instructed to find a way to do it. :(.

Could you clarify the following?
The OnKey event is probably your best bet. You could use VBA to loop
through the AllForms collection and define the event in each one,
using a one-line call to a single module.

I have created a subroutine that will add the following to each form module
and then set the form's KeyPreview to True. Is that what you are suggesting?

Private Sub Form_KeyPress(KeyAscii As Integer)
Dim strCharacter As String
' Convert ANSI value to character string.
strCharacter = Chr(KeyAscii)
' Convert character to upper case, then to ANSI value.
KeyAscii = Asc(UCase(strCharacter))
End Sub

This would be added to all 625 forms. Is there a way to trigger a forms
OnKey event from a single module eliminating the need to add this to each
form?

Your help is greatly appreciated.

Dan
 
B

Brendan Reynolds

A potential problem with this, Dan, is that it can be by-passed by copy and
paste - if a user pastes data into a text box instead of typing it, the
KeyPress event will not be fired. Using the BeforeUpdate event would be
safer, but unfortunately would involve more work.
 
G

Guest

Thanks for the 'heads up'. I realize that there is that potential and I will
need to make them aware of that if I use the 'KeyPress' event. However,
since there are thousands of text controls in this application, it would
probably be worth the risk when weighed against the time and maintenance
involve with adding code to each control's 'BeforeUpdate' event (or even if
it was done through some validation code in the forms BeforeUpdate event).

I appreciate the input though. This is something that I need to document in
case this happens in the field.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top