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

Dlookup struggle

Status
Not open for further replies.

ncopeland

IS-IT--Management
Mar 12, 2002
88
GB
Hi I have 2 forms a main form and a subform. I want to check a table for a unit cost based on the item no and customer no retrieved from the 2 forms.

Here is the code that dosent work.

Me![UnitCost] = DLookup("[Price]", "[Item-Price-File]", "[ItemUnique-No] = Forms![Purchase-Order-Input]![PO-Detail].Form![Item-No] And [Customer-No] = Forms![Purchase-Order-Input].Form![Combo90]")

Kind Regards

Neil.
 
Try

Code:
Me![UnitCost] = DLookup("[Price]", "[Item-Price-File]", "[ItemUnique-No] = " & Forms![Purchase-Order-Input]![PO-Detail].Form![Item-No] & " And [Customer-No] = " & Forms![Purchase-Order-Input].Form![Combo90])

John
 
Hi

I get a data type mismatch in criteria expression.

Thanks.

Neil.
 
How are the fields define in your DB: [tt]ItemUnique-No[/tt] and [tt]Customer-No[/tt] ?
Numbers? Text?
If text, you need single quotes around the values from your Form.

Try something like this:

Code:
Dim sCrit As String
sCrit = "[ItemUnique-No] = " & Forms![Purchase-Order-Input]![PO-Detail].Form![Item-No] & " And [Customer-No] = " & Forms![Purchase-Order-Input].Form![Combo90]

Debug.Print sCrit 

Me![UnitCost] = DLookup("[Price]", "[Item-Price-File]", sCrit)

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Thanks Andy for tweaking the thought in my head the Customer was defined wrong in the table.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top