Working SQL with the DLookup
This Dlookup is returning 4 which is correct as it is looking at 'Cereals Moderate' in 'Organic' see table below
SQL with DLookup set out the same as above but returns the incorrect value
The Dlookup should be return 30 from the NTable which is shown below, but always returns 4, which is the SNSNumber The Dlookup SNSNumber value = 4 and TheSoil value = Winter OatsNOrganic which are displayed correctly in the query result, so I don't know why it is still returning 4 when it should be returning 30. See table below
Any help would be appreciated as I am now confused as to why the Dlookup is not working!
See my Mr Excel post for images as i need to have 10 posts to include images and links! mrexcel.com/forum/showthread.php?t=516713
Code:
SELECT QueryNPSumField.Field, QueryNPSumField.SoilType, QueryNPSumField.TableCropN, QueryNPSumField.TableSNSRain, DLookUp([SoilType],'SNSRainfall',[Crop]=[TableSNSRain]) AS SNSNumber, [TableCropN] & [SoilType] AS Ntype
FROM QueryNPSumField INNER JOIN SNSRainfall ON QueryNPSumField.TableSNSRain = SNSRainfall.Crop;
This Dlookup is returning 4 which is correct as it is looking at 'Cereals Moderate' in 'Organic' see table below
SQL with DLookup set out the same as above but returns the incorrect value
Code:
SELECT QuerySNSField.Field, QuerySNSField.SNS, QuerySNSField.Ntype, DLookUp([SNSNumber],'NTable',[TheSoil]=[Ntype]) AS Expr1
FROM QuerySNSField INNER JOIN NTable ON QuerySNSField.Ntype = NTable.TheSoil;
The Dlookup should be return 30 from the NTable which is shown below, but always returns 4, which is the SNSNumber The Dlookup SNSNumber value = 4 and TheSoil value = Winter OatsNOrganic which are displayed correctly in the query result, so I don't know why it is still returning 4 when it should be returning 30. See table below
Any help would be appreciated as I am now confused as to why the Dlookup is not working!
See my Mr Excel post for images as i need to have 10 posts to include images and links! mrexcel.com/forum/showthread.php?t=516713