Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Purchase price in order form
Remco Peters 
   
2 years ago
See attached images.

I can't get the [PurchasePrice] and [TotalPurchasePrice] to be calculated in the query of my form's recordsource. As soon as I add these fields of the PurchaseT table to the SQL in the recordsource, it stops showing data in the form.

The workaround is to have the fields of the details section of my continuous form calculate / retrieve the values, but that way I can't get the sum of the TotalPurchasePriceTxt in the form footer (TotalOrderPurchase).

Unfortunately the TechHelpVideos (and ChatGpt...) can't help me.
I believe all relations are correct in my form.

What am I missing here?

Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
You are saying that PurchasePrice and TotalPurchasePrice are not working in your Query. Where is the image of the Query showing these Calculated Fields?
Remco Peters OP  @Reply  
   
2 years ago
Yeah so meanwhile I got a step further and got them working (a relation in the form query/recordsource was incorrect). But now my form is "locked". It doesn't let me add or change any data. In the form properties everything is set to yes (allow additions, allow deletions, etc.).
Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
You have 2 joins for ProductID. This will have made the Recordset Not Updateable
Kevin Robertson  @Reply  
          
2 years ago
Also see: Outer Joins
Remco Peters OP  @Reply  
   
2 years ago
I watched them both and now got it like this (see image) but still it isn't updateble.

OrderDetailsT.ProductID --> ProductsT.ProductID = all records of OrderDetailsT and only those of ProductsT whose linked fields are identical
OrderDetailsT.ProductID --> PurchaseT.ProductID = all records of OrderDetailsT and only those of PurchaseT whose linked fields are identical
OrderDetailsT.SupplierID--> PurchaseT.SupplierID= all records of OrderDetailsT and only those of PurchaseT whose linked fields are identical

What am I missing?
Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago
I got it working. I removed the PurchaseT table from the form's recordsource. I added the PurchasePrice field with a statement in the query with this:

PurchasePrice: IIf(IsNull(OrderDetailsT.SupplierID);Null;DLookUp("PurchasePrice";"PurchaseT";"ProductID=" & OrderDetailsT.ProductID & " AND SupplierID=" & OrderDetailsT.SupplierID))

See the image below for the query.

I don't know if this is a correct way of doing things, so I would like to receive some feedback on it.

Other question is if it is also possible to do this WITH the PurchaseT table in the query?
I have a feeling that my tables are not properly setup? See image below.
Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
The image below demonstrates how to make this Query updateable.
You need to remove the Join from SupplierID.
Let me know if this works for your database.
Kevin Robertson  @Reply  
          
2 years ago

Remco Peters OP  @Reply  
   
2 years ago
When I set it up like that it doesn't fill the PurchasePrice. I added the PurchaseID to the form as a check, but it doesn't fill that one in either. Something is wrong with my tables / relations and I can't figure out what. Maybe I need to explain my database a little more:

My tables:
- ProductsT holds all products that can be sold with their salesprice. A product just appears once in this table.
- SupplierT holds all possible suppliers. A supplier only appears once in this table.
- PurchaseT shows which suppliers can supply what products and at what purchase price. 1 product from ProductsT can be in the PurchaseT table multiple times because multiple suppliers can supply the same product. Of course suppliers can be in PurchaseT multiple times.
- OrderT holds general order info like data, description, ordernumber and customername. Of course an order only appears once in this table.
- OrderDetailsT stores the products for the orders in Order T. An order from OrderT can of course appear mulitple times in the OrderDetailsT table.

The OrderF form has the OrderDetailsF form as a subform. OrderF is based on OrderT and OrderDetailsF is based on OrderDetailsT.

In OrderDetailsF:
- I want to select the product from ProductsT and store ProductID in OrderDetailsT.ProductID
- I want to show the productname (doesn't need to be stored)
- I want to show the salesprice of a product (take it from ProductsT) and store it in OrderDetailsT to ensure historical pricing
- I want to add the amount of products needed for that order in OrderDetailsT.Amount
- I want to calculate amount*price = totalproductprice
- I want to select what supplier I get the product from and show the corresponding purchaseprice for that supplier from PurchaseT.
Kevin Robertson  @Reply  
          
2 years ago
OrderDetailsF is based on OrderDetailsT

Base OrderDetailF off the Query, not the Table.
Remco Peters OP  @Reply  
   
2 years ago
I just played around with it a little more and found my mistake. I changed the table relations and used the PurchaseID to link OrderDetailsT and PurchaseT (which I hadn't before). Then your solution worked correctly.

Thanks for your help!
Remco Peters OP  @Reply  
   
2 years ago

Remco Peters OP  @Reply  
   
2 years ago

Kevin Robertson  @Reply  
          
2 years ago
Great that you got it working.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/22/2026 2:28:34 PM. PLT: 0s