Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unanswered: Find Records in a Field That Contain 'all' Uppercase Text

    I'm trying to find just fields that are in all upper case. Example: I have a table with 200,000 addresses and there are some cities in all upper case.

    Most are in Upper and Lower case (Dallas) I want to find all records that contain just the City Fields in all upper case "DALLAS".

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Use an IF statement: If <field> = UCase(<field>) Then ...
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    If <field> = UCase(<field>) Then ...

    That always evaluates as true for me, regardless of the Uppercase/Lowercase composition of a field. I think that's because Access is Case Insensitive, so that Dallas and DALLAS are the same, in its eyes.

    This function will return the number of non-Upper Case characters

    Code:
    Public Function CountLowerCase(ParsedField As String) As Integer
    Dim Caps As Integer
    Caps = 0
    For i = 1 To Len(ParsedField)
     If Asc(Mid(ParsedField, i)) > 64 And Asc(Mid(ParsedField, i)) < 91 Then
       Caps = Caps + 1
     End If
    Next i
    If Caps = Len(ParsedField) Then
      CountLowerCase = 0
    Else
      CountLowerCase = Len(ParsedField) - Caps
    End If
    End Function
    So in a query you could use this as the criteria to select records where the city field was in all caps:

    CountLowerCase([CityFieldName]) = 0

    The function needs to go in a standard module. If you place it in a new module, remember to name the module something other than CountLowerCase. The Access Gnomes get confused when a function and the module it resides in have the same name, and they go on strike!
    Last edited by Missinglinq; 02-11-09 at 21:48.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Interesting. I don't know why, but I've always thought Access was case sensitive in VBA but not SQL... I know I have my own login dialogs and when evaluating the password, it is definitely case sensitive. I'll have to check it out again next time I'm fiddling with it.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    By default, Access is Case Insensitive, which is to say when using VBA. I believe you can force it to be Case Sensitive by replacing the default Option Compare Database with Option Compare Binary. Few people do, or even know that it's possible, I suspect, but that's probably what you've done for your login forms. For most other applications you'd probably want it to be Case Insensitive. Having to worry about whether all users were capitalizing certain words or not , when you go to compare them, could be very tiring.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •