where statement

D

Dries

Hi Guys,

I got the following problem I have a table

Nr Country Cost
1234 DE 1.21
1234 NL 1.28
1234 BE
1234 UK
1235 DE 1.98

Now the purpuse of my query should be that if the Cost field is empty it
should take the cost of the DE country of the number so this should be the
result

Nr Country Cost
1234 DE 1.21
1234 NL 1.28
1234 BE 1.21
1234 UK 1.21
1235 DE 1.98

Does anyone have an idea on how to solve this?
 
K

kingston via AccessMonster.com

You can do this with two queries. The first one simply finds all the records
where Country='DE'. The second one contains the table and the first query
with a left join (show all table records and only those query records that
match) on Nr. Output the first two fields from the table, and as the third
field use something like this:

CostNew: IIF(IsNull(
.[Cost]),[Query].[Cost],
.[Cost])
 
J

Jerry Whittle

SELECT Dries.Nr,
Dries.Country,
Dries.Cost,
IIf(IsNull([Cost])=False, [COST],
DLookUp("[Cost]","Dries","[Nr] =[Nr]
AND [Country] =[Country] ")) AS TheCost
FROM Dries;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Fields to column 2
fields to columns 1
fields to columns 0
Concatenate Question 2
Merge 2 tables with conditions 2
Adding fields into exisiting table 1
3 queries into 1 8
Linking two worksheets 3

Top