DLookUp-Am Lost

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Client form, ClientID,Name, Address etc; with a subform with the
following;

SELECT OrderDetail.OrderID, OrderDetail.ProductID, OrderDetail.StoreID,
OrderDetail.Date, OrderDetail.Quantity, OrderDetail.Spreading,
OrderDetail.Cartage, CCur(([Quantity]*[Spreading]+[Quantity]*[Cartage])) AS
Total FROM OrderDetail; This has been working fine.

I am trying, to get the OrderDetail.Cartage to self populate from the
Cartage tbl after the OrderDetail has been entered. I have been trying with
the following but get syntax error.

LookUp( [OrderDetail].[Cartage] FROM [Cartage]![Cost] WHERE
[Order]![ClientID]=[Cartage]![ClientID] AND
(([OrderDetail]![StoreID])=[Cartage]![StoreID]);

I have been trying to marry the lookUp into the Query SQL. Is this the
correct place?
Help appreciated and thank you inadvance
 
What is LookUp? Is that a function that you've written for your database? It
does not exist in ACCESS VBA itself. There is a DLookup function that is
used to return a value from a specific record in a table or query; perhaps
that is what you want to use. If yes, check it in Help files -- the syntax
is quite different from what you show for LookUp attempt.

It's not completely clear what you're doing here. What is the main form's
RecordSource? Is it based on the table Cartage? If yes, then, if you link
the subform to the main form using the LinkChildFields and LinkMasterFields
properties of the subform control (the control that holds the subform) --
where you put the name of the linking fields in the properties -- and if
Cartage is the linkingi field, the value will be inserted for you.

Otherwise, it's possible that DLookup may work for you. But please give us
more details about what you're doing and what your setup is. There may be
another way to do it that's easier/faster. If not, then we can assist you
with writing the proper DLookup syntax.
 
Back
Top