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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with DLOOKUP

Status
Not open for further replies.

NHogan

MIS
Aug 23, 2001
40
CA
I have a Part Number field that when is updated, populates a Part Name field. It works fine with the current 15 digit Part Number but they are changing the Part Name to be associated with the first 5 characters of the Part Number.

Ex Part No PartName
Old 123456789012345 Bracket
New 12345 Bracket

I think it sounds like a simple change but I am getting syntax errors with my code. Below is my existing code that I want to change to look at the first 5 characters of the txtPartNo field.

DLookup "[PartName]","tblPartName","txtPartNo= [PartNo]")

Can't I just do a left(txtPartNo,5) in the DLookup command? When I try I am getting a syntax error with the comma. Please help.
 
Try ("txtPartNo",5).

You're not alone,

TomCologne
 
I still get a Runtime Error 3075 with a syntax error. Any other suggestions?
 
Dlookup("[PartName]","tblPartName","txtPartNo=Left([PartNo],5)")might work.
Hopefully?!

You're not alone,

TomCologne
 
Thanks anyways, but I finally got it too work. It didn't like the Left inside of Dlookup and the problem was I had to use quotes because it was a string.

strLeftPartNo = Left(txtPartNo, 5)
DLookup("[PartName]", "tblPartName", "[PartNo] = """ & strLeftPartNo & """")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top