enviro-guy2010
asked on
Why isn't this code working in MS Access 2010?
I have created the following through the "Build" function in MS Access 2010 in Query design view under the "Field" cell. It saves fine, but when I run the query, I get "#Error" as the query result. I have read over the formula several times and I don't see a problem with it. I tried double quotation marks and single quotation marks and both led to the same result. Can anyone tell me what is wrong with the formula or offer suggestions on how to trouble shoot? Thank you!
DESC: [Products]![FBPartNumber] & " " & IIf([Products]![Pieces]="N /A","",[Pr oducts]![P ieces] & " ") & IIf([LEDStyle]![LEDStyle]= "N/A","",[ LEDStyle]! [LEDStyle] & " ") & IIf([Products]![LEDWattage ]="N/A","" ,[Products ]![LEDWatt age] & "W ") & IIf([LensType]![LensType]= "N/A","",[ LensType]! [LensType] & " ") & IIf([Products]![Voltage]=" N/A","",[P roducts]![ Voltage] & "V" & [Current]![Current] & " ") & IIf([Colors]![Color]="N/A" ,"",[Color s]![Color] & " ") & IIf([Products]![KelvinTemp ]="N/A","" ,[Products ]![KelvinT emp] & "K ") & IIf([Products]![Lumens]="N /A","",[Pr oducts]![L umens] & "LM")
DESC: [Products]![FBPartNumber] & ' ' & IIf([Products]![Pieces]='N /A','',[Pr oducts]![P ieces] & ' ') & IIf([LEDStyle]![LEDStyle]= 'N/A','',[ LEDStyle]! [LEDStyle] & ' ') & IIf([Products]![LEDWattage ]='N/A','' ,[Products ]![LEDWatt age] & 'W ') & IIf([LensType]![LensType]= 'N/A','',[ LensType]! [LensType] & ' ') & IIf([Products]![Voltage]=' N/A','',[P roducts]![ Voltage] & 'V' & [Current]![Current] & ' ') & IIf([Colors]![Color]='N/A' ,'',[Color s]![Color] & ' ') & IIf([Products]![KelvinTemp ]='N/A','' ,[Products ]![KelvinT emp] & 'K ') & IIf([Products]![Lumens]='N /A','',[Pr oducts]![L umens] & 'LM')
DESC: [Products]![FBPartNumber] & " " & IIf([Products]![Pieces]="N
DESC: [Products]![FBPartNumber] & ' ' & IIf([Products]![Pieces]='N
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
It looks like lookup tables are being used. The formula is just creating a description string using the values that have been looked up. The if statements are just saying if the value is N/A, then should nothing, else show the looked up value.
Would need to see the relationships of the tables in the queries, and some data in order to determin problem for sure.
Would need to see the relationships of the tables in the queries, and some data in order to determin problem for sure.
ASKER
That is exactly what the problem was. Thanks for your help!
>>
Not sure where the error is, but I would put this in a custom function, then call the function from the query. Heck of a lot easier to troubleshoot that way.
Beyond that, why don't you have all this in a lookup table?
Jim.