A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Instr



 
 
Thread Tools Display Modes
  #1  
Old March 1st, 2010, 10:59 PM posted to microsoft.public.access.queries
Breecy via AccessMonster.com
external usenet poster
 
Posts: 18
Default Instr

I would like to return the left of the % in my field if a % is in the field.
Currently I have the following code in my query:

Formatted_Rate: Left([Security Description],Len([Security Description])-InStr
([Security Description],"%")-1)

The problem is that this return information for every row, reguardless if
there the is % symbol in the field I am querying or not. What am I doing
wrong?

--
Message posted via http://www.accessmonster.com

  #2  
Old March 1st, 2010, 11:58 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Instr

If the field is formatted as a percentage field, the "%" isn't actually
saved in the field.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"Breecy via AccessMonster.com" u50261@uwe wrote in message
news:a460d00c15897@uwe...
I would like to return the left of the % in my field if a % is in the
field.
Currently I have the following code in my query:

Formatted_Rate: Left([Security Description],Len([Security
Description])-InStr
([Security Description],"%")-1)

The problem is that this return information for every row, reguardless if
there the is % symbol in the field I am querying or not. What am I
doing
wrong?

--
Message posted via http://www.accessmonster.com



  #3  
Old March 2nd, 2010, 12:09 AM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Instr

Use two calculated fields --
Formatted_Rate: Left([Security Description], InStr([Security
Description],"%")-1)

Check_For_%: InStr([Security Description],"%")
Criteria -- 0

--
Build a little, test a little.


"Breecy via AccessMonster.com" wrote:

I would like to return the left of the % in my field if a % is in the field.
Currently I have the following code in my query:

Formatted_Rate: Left([Security Description],Len([Security Description])-InStr
([Security Description],"%")-1)

The problem is that this return information for every row, reguardless if
there the is % symbol in the field I am querying or not. What am I doing
wrong?

--
Message posted via http://www.accessmonster.com

.

  #4  
Old March 2nd, 2010, 01:33 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Instr

On Mon, 01 Mar 2010 22:59:10 GMT, "Breecy via AccessMonster.com" u50261@uwe
wrote:

I would like to return the left of the % in my field if a % is in the field.
Currently I have the following code in my query:

Formatted_Rate: Left([Security Description],Len([Security Description])-InStr
([Security Description],"%")-1)

The problem is that this return information for every row, reguardless if
there the is % symbol in the field I am querying or not. What am I doing
wrong?


Get sneaky:

Left([Security Description] & "%", Len([Security Description]) + 1 -
InStr([Security Description] & "%","%")-1)

If Security Desription contains a percent it will find it; if not, you've
added one at the end and will return the entire string.
--

John W. Vinson [MVP]
  #5  
Old March 2nd, 2010, 02:36 PM posted to microsoft.public.access.queries
Breecy via AccessMonster.com
external usenet poster
 
Posts: 18
Default Instr

Great idea John! I fixed it yesterday and hadn't had a chance to post back.
What I did what put the % in the criteria for the security description. It
worked like a charm. It was so simple I was a little embarassed that I
didn't think of it sooner.

--
Message posted via http://www.accessmonster.com

 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:22 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.