DLookup() - Will that work?

J

Jim May

In my Subform - I'd like to use a default-value in my
UnitPrice field. ProductID is in the Record source field list and a control
for ProductID is in the form.

My tblProducts has ProductID and UnitPrice.
Can I put a Dlookup() expression in the Default Value
of my UnitPrice Control property sheet? I might accept the amt or override
it..
Tks,
 
A

Allen Browne

Default Value is not suitable, because it is applied before the new record
is started. At that time, there is no ProductID to lookup.

Use the AfterUpdate event of ProductID to lookup the price. For an example
of how to do that, open the Northdwind sample database that installed with
Access. Open the Order Details subform. It has a combo box for ProductID,
and the code is in its AfterUpdate event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top