Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Text to All Caps

Status
Not open for further replies.

lgvelez

Technical User
Jun 6, 2000
108
0
0
US
One of our mainframe programs is going away. I have converted the ascii "dump" to an Access 97, complete with front end form for data entry. The ladies doing the data entry are used to their text being converted to all caps on the fly. I understand that Access 97 does not have an input mask for all text within a text field to be converted; however, I did find code in an MS KB article:

OnKeyPress property:
Sub Field0_KeyPress (KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

Are there any other alternatives?

Thanks [sig]<p>Laura Velez<br><a href=mailto:lauravelez@home.com>lauravelez@home.com</a><br><a href= > </a><br> [/sig]
 
laura,

Use the StrCvt function, triggered by an event like Lost Focus, or Before Update.

Private Sub Form_BeforeUpdate(Cancel As Integer)

Me![strFieldname] = StrConv(Me![strFieldname], vbUpperCase)

End Sub

You can also use this same function to capitalize each word in fields with names,
addresses, etc.

Me![strCustname] = StrConv(Me![strCustname], vbProperCase)

alley [sig][/sig]
 
It would be easier just to set the Format property in both the table and form fields to &quot;>&quot;. [sig]<p>Rob Marriott<br><a href=mailto:rob@career-connections.net>rob@career-connections.net</a><br>[/sig]
 
CCTC1,

It may seem easier at first, and I used to do it that way, but I got sick of chasing those
fields thru all the other forms and reports, fixing each one. Although it may look more complicated with the function, you only have to function with it once. Its a matter of
personal taste, I guess. To each his own.

alley [sig][/sig]
 
alley,
Not to sound like I'm tooting my own horn, but I am certainly no stranger to coding. Infact, I don't enjoy working with high-level languages like VB and Access as much, I majored in C++ OOP and C Windows API (yes I am aware that C++ is considered high level). However, I can't see a logical reason in coding a text box to capitalize text when Access already provides this feature for you. You mentioned that you do this because you got sick of chasing through the fields, however, since the task of setting up the fields is only supposed to be done once; wouldn't it be more important to focus on efficiency wrather than thinking about how much time can be cut on developement? [sig]<p>Rob Marriott<br><a href=mailto:rob@career-connections.net>rob@career-connections.net</a><br>[/sig]
 
What I forgot to mention is that once you set up the Format property in the table, when do you create the fields in a form or report, Access will carry this property over for you, providing that you:
A) Set the Format property before creating the field in the form or report.
B) Create the fields in design view by selecting them from the &quot;Fields&quot; list, dragging and dropping them onto the form, or by creating the form with a wizard.

If you set up all of the properties for each field in the Table (ie. Lookup Display Control and Source, Formats, Input Masks....), then there should be no reason to do this again when creating a form. I understand that this is not always possible, the end user will constantly change their mind, thus you will have to edit the fields that you have already created in the form. However, in an ideal &quot;textbook&quot; situation, you are not supposed to even create a table before you have fully designed the database/program. Thus you would know the field properties ahead of time. Too bad this doesn't always work in the real world. [sig]<p>Rob Marriott<br><a href=mailto:rob@career-connections.net>rob@career-connections.net</a><br>[/sig]
 
I neglected to say that there will be quite a number of downloads before we reach the final &quot;dump&quot; that we will use indefinitely. I wanted to set this format within the form so that I did not have to go through each field in the table numerous times. I can just import the data, and the links will be complete. [sig]<p>Laura Velez<br><a href=mailto:lauravelez@home.com>lauravelez@home.com</a><br><a href= > </a><br> [/sig]
 
If you truly want the data to be physically formatted into capital letters then you can use alley's method, BUT you will have to go navigate through each record in the form to have the function process each record. Until you do this, the data will still be in lower case in the table or a report. If you just want to see the data capitalized, then use the &quot;>&quot; format. There is nothing wrong with alley's method. I am only arguing that Access does have a capitalize feature built in and that if you initially set it in the table, it will carry the property over into the form or report fields for you. Thus, it is NOT alot of work to do it my way. For example: in C language their is a built in increment operator &quot;++&quot;, which increments a variable by 1.
So,

MyNumber++;

is the same as:

MyNumber = MyNumber + 1;

Why would anyone do the latter? That is my point.
Thankyou =)

[sig]<p>Rob Marriott<br><a href=mailto:rob@career-connections.net>rob@career-connections.net</a><br>[/sig]
 
I agree, Rob. However the data coming from the mainframe is in all caps already, so the history will not be a problem. I am only concerned about the new data being in all caps. I will have to append several downloads to capture the whole history.

Thanks. [sig]<p>Laura Velez<br><a href=mailto:lauravelez@home.com>lauravelez@home.com</a><br><a href= > </a><br> [/sig]
 
all participants,

It is delightful to see a storm of activity, opinions and experience explode when one stirs up the pot with an opinion stick.

Planning and communication is necessary for any project. Written specs agreed to by all can be dust in a Kansas wind when the user sees what he/she has wrought. Changes are not an interruption in the flow; they are part of the plan. Not part of the plan are the inconsistencies of the access software, where some things do not work in all places; namely the '<' Format property, for just one.

lgvelez, CCTC1 has said it all. If you want the data written to the disk capitalized like the data being imported, use the function. If you just want the data to look like it is capitalized, use '<' Format property. Access may even work.

It's been fun. Please don't let me get the last word.

alley

[sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top