Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old March 9th, 2004, 02:24 PM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default A query to extract part of a string

I am trying to build a query to look through a list for entries that end with a number enclosed in parentheses. Any suggestions?

Reply With Quote
  #2 (permalink)  
Old March 9th, 2004, 04:36 PM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 20%
Activity: 20% Activity: 20% Activity: 20%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

In your query's criteria section for that field, enter this as the criteria:

Like "*(?)"
Like "*(??)"

The first one gives you any one-digit number. The second gives you any two-digit number, etc. Remember to include the word LIKE in your criteria. It's a key word.

The * wildcard signifies that anything can be before the (.
The ? wildcard(s) signifies that one (two, etc.) characters can be inside the ().



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
Reply With Quote
  #3 (permalink)  
Old March 10th, 2004, 04:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Oxford, , United Kingdom.
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If there's a possibility that the brackets at the end of the string may contain letters, you can make the pattern even more exact by using the following:

Like "*([0-9])"
Like "*([0-9][0-9])"

Where [0-9] means ensure that the character in this position is between 0 and 9.


Brian Skelton
Braxis Computer Services Ltd.
Reply With Quote
  #4 (permalink)  
Old March 10th, 2004, 08:42 AM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Greg, Brian .... thanks guys, it worked great. I also needed to get a field that contained only the four digit number, but I worked that out myself. Thanks again... Ray

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract part of String carrie09 Access 6 August 24th, 2007 10:04 AM
Extract first numeric string blkskullwork Javascript 1 November 6th, 2006 01:37 AM
how to extract from a string fraijo SQL Server 2000 3 October 25th, 2006 09:55 PM
Getting Part of a String needelp Access VBA 4 September 19th, 2006 06:22 AM
Extract part of field from inconsistent data Roly Reefer Access VBA 4 March 31st, 2005 08:25 AM



All times are GMT -4. The time now is 06:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.