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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting the Case of a Record 1

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
US
I'm trying to write an update query that will change the value of a checkbox if the record in a field is all in upper case. I know how to convert the case of a record but I need some help detecting the case of a entry in a record.

Thanks, Kopy
 
There is no function in VBA that I am aware of to do this so you will need to create your own.

I would create one that loops through each character in the string and checks the value of the ASCII code of the character.

Lower-case letters have ASCII code values between 97 and 122 so if any of the values are within this range the text is not *all* in upper case.

Ed Metcalfe.

Please do not feed the trolls.....
 
Put this Function in a module

Code:
Option Compare Database
Option Explicit

Function myUpperCheck(strCheckString As String) As Boolean

If StrComp(strCheckString, UCase(strCheckString), vbBinaryCompare) Then
    myUpperCheck = False
Else
    myUpperCheck = True
End If
End Function

And this is your update query
[Code SQL Statement]
UPDATE yourTableNameHere
SET yourFieldNameToUpdate = TRUE
WHERE myUpperCheck(yourFieldNameToCheck) = True
[/code]
 
Nice solution Jerry. Have a star! :)

Ed Metcalfe.

Please do not feed the trolls.....
 
Thanks Ed.

First I was thinking about using a simple IF block to check the string with its UCASE and OPTION COMPARE BINARY but then remembered the StrComp.

One great thing of posting a possible solution is that it makes you use the idle time of the brain!
[cheers]
 
One great thing of posting a possible solution is that it makes you use the idle time of the brain!

It's important to use those spare CPU cycles. :)

Ed Metcalfe.

Please do not feed the trolls.....
 
Thanks for your help.
Take care, Kopy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top