Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question

Status
Not open for further replies.

wally2321

Technical User
May 30, 2001
64
US
Once again I have a question... I have the following code in my query -

NO: IIf(Left([MATERIAL NUMBER],1)="F" Or Left([MATERIAL NUMBER],1)="Z" Or Left([MATERIAL NUMBER],1)="S" Or Left([MATERIAL NUMBER],1)="E",Right([MATERIAL NUMBER],Len([MATERIAL NUMBER])-1),[MATERIAL NUMBER])


I am using the Design feature of the Make query. If I wanted to further define the data to only return if the number falls in a certain range, how could that be done?

So if the above is true, but only should be returned if the number falls between .......

3000000 - 99999999

Anyone have an idea on how I can add this logic to my existing line of code above?

Wally
 
FLORENCE SCRUBBER - MAKE.[MATERIAL NUMBER],
FLORENCE SCRUBBER - MAKE.[PRODUCTION CODE]

This contains the '-' sign which will confuse it. It will think you are trying to do a substraction.

try

[FLORENCE SCRUBBER - MAKE].[MATERIAL NUMBER],
[FLORENCE SCRUBBER - MAKE].[PRODUCTION CODE]

or remove the - from your table name
 
Ok guys........I am still having a problem...after taking your advise, I have the following code:

SELECT
[FLORENCE SCRUBBER - MAKE].[MATERIAL NUMBER],
[FLORENCE SCRUBBER - MAKE].[PRODUCTION CODE]
FROM [ FLORENCE SCRUBBER - MAKE]
WHERE (((Left([MATERIAL NUMBER],1))="E"
Or (Left([MATERIAL NUMBER],1))="F"
Or (Left([MATERIAL NUMBER],1))="S"
Or (Left([MATERIAL NUMBER],1))="Z")
AND ((CLng(Right([MATERIAL NUMBER],Len([MATERIAL NUMBER])-1))) Between 3000000 And 99999999)
AND ((Left([PRODUCTION CODE],4))="HIBE")) ;


When trying to run the program, I am given the following error:

Invalid bracking of name 'FLORENCE SCRUBBER - MAKE'.

Any ideas?!!!
 
Ok... Now I have the following:

SELECT
[FLORENCE SCRUBBER - MAKE].[MATERIAL NUMBER],
[FLORENCE SCRUBBER - MAKE].[PRODUCTION CODE]
FROM [FLORENCE SCRUBBER - MAKE]
WHERE (((Left([MATERIAL NUMBER],1))="E"
Or (Left([MATERIAL NUMBER],1))="F"
Or (Left([MATERIAL NUMBER],1))="S"
Or (Left([MATERIAL NUMBER],1))="Z")
AND ((CLng(Right([MATERIAL NUMBER],Len([MATERIAL NUMBER])-1))) Between 3000000 And 99999999)
AND ((Left([PRODUCTION CODE],4))="HIBE")) ;

I receive the following error code now:

Data type mismatch in criteria expression

Any ideas?!
 
I suspect that the [Material Number] isn't all numeric after the letters "E", "F", "S" and "Z". This poses some problems with search criteria but initially causes the Type Mismatch error in the CLng function. Replace OLD section of the SQL with the NEW SQL.

OLD:
AND ((CLng(Right([MATERIAL NUMBER],Len([MATERIAL NUMBER])-1))) Between 3000000 And 99999999)

NEW:
AND ((CLng(IIf(IsNumeric(Right([Material Number],Len([Material Number])-1)),Right([Material Number],Len([Material Number])-1),0)) Between 3000000 And 99999999)
Terry

"I'm not dumb. I just have a command of throughly useless information." - Calvin, of Calvin and Hobbes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top