Update Query with update to Dlookup

skippypower

Registered User.
Local time
Today, 10:07
Joined
Jan 6, 2012
Messages
10
I have a update query where i am updating a table called tblPartSetEdit. tblPartSetEdit has the fieldsPartIDand CostofComponent.

I am looking to update from a table called data-tblCasting that has fields ID and CastingCost.

Ii am trying to update the field CostofComponent to a value from CastingCost where ID and PartID are the same. In the update to box in the query i have:

DLookUp("CastingCost","data-tblCasting","ID=PartID")



All I seem to get is a message box saying unknown! :mad:


Sorry if i haven’t explained this to well. Any pointing in the right direction would be great! It seems so simple but just wont work. Thanks.
 
Assuming PartID is a number then this is what you need:

DLookUp("CastingCost","data-tblCasting","ID=" & PartID)

If its text, this is what you need:

DLookUp("CastingCost","data-tblCasting","ID='" & PartID & "'")

You weren't using PartID as a variable, the ways I have posted do.
 
Hey Plog, Afraid I’m getting the same message box saying unknown with those as well. Although I do get a help button with this message box that links to "Data type mismatch in criteria expression. (Error 3464) The criteria expression in a Find method is attempting to compare a field with a value whose data type does not match the field's data type"

In the tables both the ID and PartID are set as numbers and CostofComponent and CastingCost are currency.
 
I have it working now!! yay!! i ended up using the code:

DLookUp("CastingCost","data-tblCasting","ID=" & [PartID])

Just needed some brackets round PartID! Thanks Plog!
 

Users who are viewing this thread

Back
Top Bottom