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

ucase function

P: n/a
I need to define a field so that when a lowercase letter is put in the
field it turns to an uppercase letter. What would the expression for
the field be? My field name is site_id.

Jan 9 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a

ts*****@cetusgroup.com wrote:
I need to define a field so that when a lowercase letter is put in the
field it turns to an uppercase letter. What would the expression for
the field be? My field name is site_id.


I use this function. I am sure there may be other methods, but I have
found this to work every time. Call the function in the After Update
event of the site_id text box.

Public Function Capitalize(str As String)

Dim i As Integer
Dim wasspc As Boolean

wasspc = True

For i = 1 To Len(str)
If wasspc Then
str = Left$(str, i - 1) & UCase(Mid(str, i, 1)) & Right(str,
Len(str) - i)
End If
wasspc = IIf(Mid(str, i, 1) = " ", True, False)
Next i

Capitalize = str

End Function

Jan 9 '06 #2

P: n/a


Should I just paste and copy that code into access or do I need to
change anything?

*** Sent via Developersdex http://www.developersdex.com ***
Jan 9 '06 #3

P: n/a


I tried the code you gave me and it did not work. is there anything that
I can do like just create an expression to make the letter in the field
automatically capitalize.

*** Sent via Developersdex http://www.developersdex.com ***
Jan 9 '06 #4

P: n/a

<ts*****@cetusgroup.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I need to define a field so that when a lowercase letter is put in the
field it turns to an uppercase letter. What would the expression for
the field be? My field name is site_id.


The simplest way to do this is in the design of the table, select the field
and into the format property write ">" (without the quotes, ie >).
This will not change the data as lower case letters will still be held in
the table, it just forces them to appear as upper case. If you have to make
sure that no lower case letters are entered into the table, then the only
way is to write code in the form where you enter the data. However, the
solution above is quick, simple and may do all you require.
Jan 9 '06 #5

P: n/a
ts*****@cetusgroup.com wrote:
I need to define a field so that when a lowercase letter is put in the
field it turns to an uppercase letter. What would the expression for
the field be? My field name is site_id.

Do you need to check as the data is input? Why not simply uppercase the
entire field in the afterupdate event of the field. Ex:
Me.Field1 = Ucase(Me.Field1)
Jan 9 '06 #6

P: n/a
<ts*****@cetusgroup.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I need to define a field so that when a lowercase letter is put in the
field it turns to an uppercase letter. What would the expression for
the field be? My field name is site_id.


Two options:

1) In the KeyPress Event:
This option changes data as you type

Private Sub site_id_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub

2) In the AfterUpdate Event:
This option changes the entire field after you leave

Private Sub site_id_AfterUpdate
Me.site_id = Ucase(Me.site_id)
End Sub

Fred Zuckerman
Jan 9 '06 #7

P: n/a
<ts*****@cetusgroup.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I need to define a field so that when a lowercase letter is put in the
field it turns to an uppercase letter. What would the expression for
the field be? My field name is site_id.

Todd, I don't know of anything that can force a field in a table to upper
case except for a validation rule (messy). It's easy, however, in a control
on a form. This is what I use for that (note it is the Change event for the
text box):

Private Sub tbxCriteriaValue_Change()
Dim intPos As Integer
intPos = Me.tbxCriteriaValue.SelStart
Me.tbxCriteriaValue = UCase(Me.tbxCriteriaValue.Text)
Me.tbxCriteriaValue.SelStart = intPos
End Sub
--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.

Jan 9 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.