Dlookup! (1 Viewer)

IanDuk

New member
Local time
Today, 18:25
Joined
Aug 20, 2019
Messages
8
Hi

I am trying to right an invoicing application and using Dlookup on a report to have it automatically bring in the billing addresses. I have trawled the web to find the correct code but it keeps giving me an error :banghead:

So you can see what I am trying to achieve here is an example of code I have tried.

As a control source in a text box

Dlookup("[Unit_Address]","[tbl_Units]","[Unit_Code]=" [cbo_unit])

cbo_unit is a combo box on the report.

I have read somewhere there is a difference between txt and number code?

I know its probably something simple but I am new to this kind of coding.

Please help. Getting very frustrating.

Many Thanks.
 

Minty

AWF VIP
Local time
Today, 18:25
Joined
Jul 26, 2013
Messages
10,355
You can probably link the billing address in the underlying query and bring it in to your form more efficiently, however to answer your question try

Code:
Dlookup("[Unit_Address]","[tbl_Units]","[Unit_Code]=" & Me.cbo_unit)

Me is used to refer to the current forms objects.
 

isladogs

MVP / VIP
Local time
Today, 18:25
Joined
Jan 14, 2017
Messages
18,186
If Unit Code is a number field then
Dlookup("Unit_Address","tbl_Units","Unit_Code=" & me.cbo_unit)

If its a text field then you need text delimiters
Dlookup("Unit_Address","tbl_Units","Unit_Code='" & me.cbo_unit &"'")

Note that you can omit all the [] as the names do not contain spaces or special characters
 
Last edited:

IanDuk

New member
Local time
Today, 18:25
Joined
Aug 20, 2019
Messages
8
:) Thank you both!

isladogs thanks for pointing out the differences. Now I am finally getting somewhere!
 

usama_hawas

Registered User.
Local time
Today, 11:25
Joined
Aug 20, 2019
Messages
10
thank you but it Dlookup very Slow is there any way faster
 

Users who are viewing this thread

Top Bottom