Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a DLookUp Function without criteria 1

Status
Not open for further replies.

ImStuk

Technical User
Feb 20, 2003
62
US
I am trying to add my company name, address etc... to the top of a report. My company information isn't related to anything so I am trying to use the DLookUp function. However, I have never done DLookUp without criteria and I keep getting a syntex error. I have no problem when I use:

DLookUp("[MyCompanyName]","tblMyCompany") 'This works'

But when I want to add multiple fields to one line it's not working. This is what I have been trying:

DLookUp("[MyCompanyAddress]& ' ' & [MyCompanySuite]", "tblMyCompany")

Can somebody please point me in the right direction? Thank you.
 
Hi!

Think you'll have to use two ore more dlookup's, and then concatinate them (one per field you want to retrieve), for instance:

[tt]Myvar=DLookUp("[MyCompanyName]","tblMyCompany") & " " & DLookUp("[MyCompanySuite]","tblMyCompany")[/tt]

HTH Roy-Vidar
 
Roy V. to the rescue once again. Works great like that.

Apparently I don't understand the DLookUp function because I use the following with criteria and it works...

=DLookUp("[FirstName] & ' ' & [LastName]", "tblEntity", "EntityID = '" & [txtEntityID] & "'")
 
Hi again!

I don't use those functions much, but just tested it, and had DLookup return four fields without any critierias... So now I learned something new;-)

I'm using just the same code you provided, whith my table/field names...

So have a star yourself!

Roy-Vidar
 
Thank you. Turns out it works without the criteria. I just forgot to put = before the darn function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top