Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2011, 05:28 PM
Registered User
 
Join Date: Jul 2007
Posts: 9
Thanks: 6
Thanked 0 Times in 0 Posts
Default Field value Contains Alpha char up to Space

I am looking for a phrase based on if a field (NAME) has 4 characters or more. If the field starts with 4 characters or more. I want to take everything up to the first space or the end of the field, whichever comes first, and put that into another field called (SECNAME).

Bob
 
Old April 12th, 2011, 06:01 PM
Authorized User
 
Join Date: Oct 2010
Posts: 64
Thanks: 0
Thanked 16 Times in 16 Posts
Default

First NEVER use NAME as a field name it's a reserved word!

To filter out the NAMEs with 4 characters use Like "[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-z]*" in the criteria of a query. That will give you all the records with 4+ characters in NAME.

To obtain SECNAME use IIf(InStr([NAME]," ")>0,Left([NAME],InStr([NAME]," ")-1),[NAME]) in the same query in a Field. If you run the query you will have a list of all your SECNAMEs. You can then use this query to update your new SECNAME field.

Copy and paste this into a new query in SQL View (change Table4 to your table name).

SELECT IIf(InStr([NAME]," ")>0,Left([NAME],InStr([NAME]," ")-1),[NAME]) AS newSECNAME
FROM Table4
WHERE (((Table4.NAME) Like "[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-z]*"));

HTH.

Malc.
The Following User Says Thank You to malcolmdixon For This Useful Post:
amerifax (April 19th, 2011)
 
Old April 12th, 2011, 06:40 PM
Registered User
 
Join Date: Jul 2007
Posts: 9
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Name - Reserved Thanks

Does the [] exclude any value that is in between the brackets?

What does []* "*" do to the value?

Thanks for the help.

Bob
 
Old April 13th, 2011, 04:48 AM
Authorized User
 
Join Date: Oct 2010
Posts: 64
Thanks: 0
Thanked 16 Times in 16 Posts
Default

[] includes the range of characters inside the brackets, that is a to z AND A to Z. You can use a ! to exclude characters, that is Like "[!a-d]*" would filter OUT records with a to d as first character.

The * is a wildcard that indicates selection of zero or more characters.

Please read the Help section on "Using Wildcard Characters in String Comparisons".

Malc.
The Following User Says Thank You to malcolmdixon For This Useful Post:
amerifax (April 19th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for alpha in a string abbylee26 Javascript How-To 2 April 12th, 2011 06:44 PM
Strings (differences between an array of char and *char) gabberfrombcn C++ Programming 2 August 30th, 2010 08:02 PM
Big challenge here! How to convert char* to char^? samiswt Visual C++ 2005 1 November 30th, 2007 09:09 PM
Invalid conversion from 'char*' to 'char' deuxmio C++ Programming 3 December 8th, 2006 07:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.