Results 1 to 3 of 3
  1. #1
    jset818 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    38

    Question Extract numbers from a text string and keep format as Number?

    Hi everybody, beginner Access user here. I’m trying to extract numbers from a text string and keep the results as number. Please take a look at the screenshot below.
    Click image for larger version. 

Name:	Capture.JPG 
Views:	12 
Size:	15.3 KB 
ID:	22452
    As you can see from the first column, I was able to extract the numbers that I want by using the function Right([Event ID],4). However, the results it return for me is in text format. I need those numbers to be in number format so I can use them as a join for another table. Or else every time I try to run it with the join, it would say "Data type mismatch" (I think that is what's causing the error). I have tried using function like this, Format([expr 1],"General Number") and changing the format of the Table in Excel but to no success.

    Basically I have two tables, one with Event IDs like the first column and another with Event IDs like the 2nd column from the screenshot. I want them both to have 4 digit Event IDs (like 1st column) so I can link them together. Any suggestions on how I can make this work?



    Thanks,
    J

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Format() and FormatNumber() always return a text value no matter what parameter is used.

    Try CInt(Right([Event ID],4)) or Val(Right([Event ID],4)).
    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
    jset818 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Sep 2014
    Posts
    38
    Quote Originally Posted by June7 View Post
    Format() and FormatNumber() always return a text value no matter what parameter is used.

    Try CInt(Right([Event ID],4)) or Val(Right([Event ID],4)).
    The CInt(Right([Event ID],4)) function worked. Thanks!

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

Similar Threads

  1. Extract number from String
    By DOSRoss in forum Programming
    Replies: 26
    Last Post: 04-28-2015, 06:07 AM
  2. function to extract numbers from string
    By Ruegen in forum Programming
    Replies: 4
    Last Post: 04-12-2015, 07:59 PM
  3. Extract a number from a string
    By webisti in forum Access
    Replies: 3
    Last Post: 09-16-2013, 08:29 AM
  4. Convert Number to String in .csv extract
    By CindyR19 in forum Import/Export Data
    Replies: 3
    Last Post: 08-17-2011, 02:58 PM
  5. Extract numbers from text string strored in a field.
    By khabdullah in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 06:55 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