#Num! error in Right join Query (1 Viewer)

AnilBagga

Member
Local time
Today, 11:16
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:46
Joined
May 7, 2009
Messages
19,231
... IIf(IsNull([recipecostperkg]), 0, [recipecostperkg]) AS RKG
 

AnilBagga

Member
Local time
Today, 11:16
Joined
Apr 9, 2020
Messages
223
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;
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:46
Joined
Oct 29, 2018
Messages
21,454
How about?
Code:
IIf([recipecostperkg] & ""="",0,[recipecostperkg]) AS RKG
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:46
Joined
May 7, 2009
Messages
19,231
can you use Val() function:

Val([recipecostperkg] & "") AS RKG
 

AnilBagga

Member
Local time
Today, 11:16
Joined
Apr 9, 2020
Messages
223

[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
 

AnilBagga

Member
Local time
Today, 11:16
Joined
Apr 9, 2020
Messages
223
How about?
Code:
IIf([recipecostperkg] & ""="",0,[recipecostperkg]) AS RKG
Does not help

I think the issue is the data in qryCoatingRecipeHdr.CoatingCode.

If I use tables in a mock qry as enclosed, I don't face any issue
 

Attachments

  • PP_Test_error_27 May.zip
    114.6 KB · Views: 413

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 13:46
Joined
May 7, 2009
Messages
19,231
its very hard to guess

IIF([recipecostperkg] & "" = "#num!", 0, [recipecostperkg]) as RGK
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:46
Joined
Feb 19, 2002
Messages
43,223
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

Top Bottom