DLookup

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

DLookup

Post by D Willett »

Aaaargh

Trying to get the customer onto my form using DLookup.

DLookup("Customer", "tblSales", "SalesOrderID = " & Forms![frmSales]!SalesOrderID)

Should return the "Customer" from "tblSales" where "SalesOrderID" from "tblSales" = "SalesOrderID" on the current form "frmFitting"

:hairout:
Cheers ...

Dave.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: DLookup

Post by Rudi »

You say your current form is called frmFitting, but the expression refers to the form frmSales?

Maybe this: =DLookup("Customer", "tblSales", "SalesOrderID = " & Forms![frmFitting]!SalesOrderID)
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

D Willett
SilverLounger
Posts: 1728
Joined: 25 Jan 2010, 08:34
Location: Stoke on Trent - Staffordshire - England

Re: DLookup

Post by D Willett »

Just the Job Rudi .

Thanks
Cheers ...

Dave.

Sgte
2StarLounger
Posts: 164
Joined: 10 Feb 2010, 12:53

Re: DLookup

Post by Sgte »

Help please: I am struggling to get my DLookup working
Its parameters are Client name is the field I want returned, from the QueryAllClientnames2 where TRIndCode is in the query I am woking in equals the field Code in the query all clint names 2
=DLookUp("Client Name","QryAllClientNames2","TRIndCode =" [QryAllClientNames2]!

Code: Select all

 ")

What have I got wrong please?

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DLookup

Post by HansV »

If Code is a number field:

=DLookUp("Client Name","QryAllClientNames2","Code=" & [TRIndCode])

If Code is a text field:

=DLookUp("Client Name","QryAllClientNames2","Code=" & Chr(34) & [TRIndCode] & Chr(34))

Chr(34) is the double quote character ".
Best wishes,
Hans

Sgte
2StarLounger
Posts: 164
Joined: 10 Feb 2010, 12:53

Re: DLookup

Post by Sgte »

I regret that having pasted both of your lines of code into the expression builder that they don't work! :-( Any further thoughts please?

User avatar
HansV
Administrator
Posts: 78620
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DLookup

Post by HansV »

I'd have to see a copy of the database...
Best wishes,
Hans

Sgte
2StarLounger
Posts: 164
Joined: 10 Feb 2010, 12:53

Re: DLookup

Post by Sgte »

Ok, thank you very much Hans.