#Num! error in Right join Query

AnilBagga

Member
Local time
Tomorrow, 03:40
Joined
Apr 9, 2020
Messages
223
I have a simple query where I use a right join. If an item is not found in the right joined table, it gives an error

Many values of Lamcode in the tblUncoatedFabCost are blank. In these cases I get a #Num! error in the query. How can I get 0 instead of the error as I need to use this value in a sum function?

Using Nz function on recipecostperkg did not help and I tried the IIF function as below. No help either!

I dont know VBA and use the QBE window in Design view to create queries

SELECT tblUncoatedFabCost.FGCode, tblUncoatedFabCost.FabCode, tblUncoatedFabCost.LamCode, tblUncoatedFabCost.UncoatedFabCostPerKg AS UFKG, tblUncoatedFabCost.UncoatedFabCostPerSQM AS UFSQM, IIf([recipecostperkg] Is Null,0,[recipecostperkg]) AS RKG FROM tblUncoatedFabCost LEFT JOIN qryCoatingRecipeHdr ON tblUncoatedFabCost.LamCode = qryCoatingRecipeHdr.CoatingCode;
1622085808980.png

1622085721547.png
 
... IIf(IsNull([recipecostperkg]), 0, [recipecostperkg]) AS RKG
 
Same error. Modified SQL is as below

Code:
SELECT tblUncoatedFabCost.FGCode, tblUncoatedFabCost.FabCode, tblUncoatedFabCost.LamCode, tblUncoatedFabCost.UncoatedFabCostPerKg AS UFKG, tblUncoatedFabCost.UncoatedFabCostPerSQM AS UFSQM, IIf(IsNull([recipecostperkg]), 0, [recipecostperkg]) AS RKG
FROM tblUncoatedFabCost LEFT JOIN qryCoatingRecipeHdr ON tblUncoatedFabCost.LamCode = qryCoatingRecipeHdr.CoatingCode;
 
How about?
Code:
IIf([recipecostperkg] & ""="",0,[recipecostperkg]) AS RKG
 
can you use Val() function:

Val([recipecostperkg] & "") AS RKG
 
[QUOTE="arnelgp, post: 1768302, member: 64504"] can you use Val() function: Val([recipecostperkg] & "") AS RKG [/QUOTE] [CODE]SELECT tblUncoatedFabCost.FGCode, tblUncoatedFabCost.FabCode, tblUncoatedFabCost.LamCode, tblUncoatedFabCost.UncoatedFabCostPerKg AS UFKG, tblUncoatedFabCost.UncoatedFabCostPerSQM AS UFSQM, Val([recipecostperkg] & "") AS RKG FROM tblUncoatedFabCost LEFT JOIN qryCoatingRecipeHdr ON tblUncoatedFabCost.LamCode = qryCoatingRecipeHdr.CoatingCode; [/CODE]
1622093335155.png
 
its very hard to guess

IIF([recipecostperkg] & "" = "#num!", 0, [recipecostperkg]) as RGK
 
You didn't include the query with the issue. We have no idea what the hidden query is doing.
 

Users who are viewing this thread

Back
Top Bottom