MS Access Created default value on form field, not showing
Olivia Zamora
I have an Inventory table set up like this:
ItemCodeis the primary keySalesPrice
I have a WSales table with:
IDas primary keyItemCode(duplicates allowed)SalesPriceSalesQty
On the capture form I want to capture the SalesQty and the SalesPrice for an ItemCode. This SalesPrice is usually the same as the SalesPrice field in the Inventory table but it could vary. So to save capture time I would like the SalesPrice from Inventory to show on the form as the default value.
I have created a default value for SalesPrice on the form as
=[Inventory]![SalesPrice]Does not work as the form field remains empty
The two tables are linked by ItemCode in a one to many relationship
Any suggestions would be most welcome.
By the way, new to Access so not yet up to speed on VBA or SQL
Using Access in Office365
1 Answer
I believe the problem is that you are specifying a field where you want to return a single value. How should Access know which member of the SalesPrice field you want to return?
The answer is a query. In Access the command is called DLOOKUP. It would go something like this:
=DLookUp("[WholeSalePrice]","[Inventory]","[ItemCode]=" & Forms![WorkShop Sales Capture]![ItemCode])This is like an SQL query that says give me the SalesPrice from the Inventory table where the ItemCode is the same as the ItemCode on Form Capture. You will have to ensure that the form name is correct. I put "Capture" in there because that is what you called the form.
3