Results 1 to 5 of 5
  1. #1
    csdlman is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2016
    Posts
    17

    Finding records containing uppercase letters


    I have a very simple table containing text string values and I need to isolate those records that contain one or more uppercase letters. Is there a handy way to do this, aside from the totally inelegant method of individually testing for each letter?

    Thanks!

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    One way is to create your own User Defined Function to do this, like this:
    Code:
    Function HasCaps(myString As Variant) As Boolean
    '   Check for the existence of one or more caps in a string
    
        Dim i As Long
        Dim num As Integer
    
    '   Set initial value to false
        HasCaps = False
        
    '   Exit if no entry
        If Len(myString & "X") = 1 Then Exit Function
       
    '   Loop through all characters
        For i = 1 To Len(myString)
    '       Get ASCII code of character
            num = Asc(Mid(myString, i, 1))
    '       If ASCII code between 65 and 90, it is a cap
            If (num >= 65) And (num <= 90) Then
                HasCaps = True
                Exit Function
            End If
        Next i
    
    End Function
    Then you would use this like any other function in your query, i.e.
    CapsCheck: HasCaps([FieldName])

    This will return TRUE (or -1) if the entry has any caps, and FALSE (or 0) if it does not.

  3. #3
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    This thread has a very cunning way of doing this
    https://access-programmers.co.uk/for...ad.php?t=61453

    By comparing the string to itself converted to Lower case.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    This thread has a very cunning way of doing this
    https://access-programmers.co.uk/for...ad.php?t=61453

    By comparing the string to itself converted to Lower case.
    Very clever! That is certainly simpler than creating a UDF.

  5. #5
    csdlman is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Dec 2016
    Posts
    17
    Thank you, this is helpful.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-22-2018, 07:47 AM
  2. finding new records for a given period
    By zburns in forum Queries
    Replies: 3
    Last Post: 04-12-2015, 06:17 PM
  3. Count uppercase letters
    By Misha in forum Access
    Replies: 8
    Last Post: 03-01-2012, 10:37 AM
  4. Return records where ID contains leading letters
    By mkallover in forum Queries
    Replies: 1
    Last Post: 01-18-2012, 10:31 AM
  5. Finding Records that are not there!
    By TrudyD1474 in forum Queries
    Replies: 2
    Last Post: 06-18-2010, 04:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums