Results 1 to 4 of 4
  1. #1
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150

    Function to find a number in string


    Is there a function available that I can determine whether a field has a number in the string? For an example, "DJ007Hhg" returns Yes and "Heghelz" returns No.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Have to roll your own. Example http://www.utteraccess.com/forum/Fin...-t1746052.html

    An expression in query or textbox can return True/False, no VBA required.

    IIf([fieldname] LIKE "*[0-9]*", True, False)

    Do you need to know what the number is? Will it always be only one digit?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Try
    Code:
    Function HasNumber(sInput As String) As Boolean
     HasNumber = IIf(sInput Like "*[0-9]*", True, False)
    End Function

  4. #4
    LonghronJ is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Posts
    150
    Quote Originally Posted by June7 View Post
    Have to roll your own. Example http://www.utteraccess.com/forum/Fin...-t1746052.html

    An expression in query or textbox can return True/False, no VBA required.

    IIf([fieldname] LIKE "*[0-9]*", True, False)

    Do you need to know what the number is? Will it always be only one digit?
    I just need to know if one exists. This works perfectly. Thanks.

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

Similar Threads

  1. find last object by spliting string
    By Mbakker71 in forum Access
    Replies: 2
    Last Post: 01-29-2014, 12:10 PM
  2. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  3. Trying to find a value right of specific string with in text
    By weilerda in forum Import/Export Data
    Replies: 2
    Last Post: 10-18-2012, 12:58 PM
  4. find all text string in Criteria at once
    By Jerseynjphillypa in forum Queries
    Replies: 3
    Last Post: 05-15-2012, 12:12 PM
  5. Find first Capital letter in string
    By Dutch1956 in forum Programming
    Replies: 5
    Last Post: 09-07-2011, 03:14 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