Complex DLookup

dunnes

Board Regular
Joined
May 21, 2003
Messages
69
Hi,
as Dlookups seem to be the topic of the day i thought i would add my own. I have a dlookup which seems correct but doesnt bring out the correct result.

Lead Targets: DLookUp("[Leads]","[tblTargets2005]","[Week]='weekNumber'" And "[Branch_ID]='Branch'")

The bit im not so sure about is the and statement to add a second criteria.
The report should print each branch number out (209) with the targets according to the branch number and the week number. Problem is it only seems to return the first target value in the target table....and not actually lookup againt the branch value.....which is why im wondering if the and statement is correct


Cheeers
Mike
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi Mike,

If it is how you pasted above then I think it should be like following:

Lead Targets: DLookUp("[Leads]","[tblTargets2005]","[Week]='weekNumber' And [Branch_ID]='Branch'")

You should use only one string for the criteria, not split them, just use as you would use in a sql query text.

I hope it helps.
Suat
 
Upvote 0
Do you actually need to use a DLOOKUP? Can't you create a join between tables/queries?

Is that the exact expression you are using?

As fas as I can see it would match the word 'weekNumber' to the Week field and the word 'Branch' to the Branch_ID field.

Should it not be something like this:

Lead Targets: DLookUp("[Leads]","[tblTargets2005]","[Week]=" & weekNumber & " And [Branch_ID]=" & Branch)

BTW Is this expression in a query, report or form?
 
Upvote 0
Cheers Guys i was trying to overcomplicate the matter, Norie was right all i needed to do was link the tables.....beginners mistake

Thanks again
Mike
 
Upvote 0

Forum statistics

Threads
1,221,845
Messages
6,162,350
Members
451,760
Latest member
samue Thon Ajaladin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top