Help with a cafe database

Hello, I'm new here but if possible, I'd like to ask for some help regarding a database I'm working on.

You see, I'm currently creating a mock cafe database that must be able to accept information regarding customers, their orders, and items sold by the cafe. From this, I have identified the three main data values needed for the database's tables, which are customer, Item, Order and Order Item, respectively. Below is an images showing my database's relationship diagram, with the tables and their internal information.

Relationships:


Currently, I have finished the tables and the forms used to input the customer, items and orders, but I am currently having issues involving the calculation of the price of orders. You see, when a user wants to make an order, they use the form shown on the form shown below:

 

On this form, the user selects a customer ID number, followed by entering the order date and collection time, while an order number is automatically generated. The whitebox is a subform,where the user selects an item ID (which also shows the item's name and cost when browsing through its combobox), enters the quantity of the item being ordered, and adds any additional information or price supplement if necessary. As can also be seen, once the user selects an item ID, another box automatically appears in the subform where the user can enter another item and its details if necessary. Once the user is done, they then select the "Save Record" button, which saves the order into the "Order" and "Order Item" tables.

Now, the issue I have is that I need to create a form that acts as an invoice for the order, which shows two calculations, the total price of multiple items of the same type within an order added any price supplements they have (eg, the cost of two coffees within an order, + a supplement of 20p) and total cost of an entire order (eg, the total price of the two coffees and supplement, + the price two sandwiches, to give the order's total cost). I have already figured out the first calculation through the query in the image below:

Item Cost Query (Design View):

So the issue I have is creating a query that calculates the total cost of an order, which is the prices of all items within an order added together. I have tried several times but without success. I am also unsure as to how to display the results of these queries into my currently unmade invoice form and to format said form and ensuring reports so that they only show the calculations for the saved order. If anyone could help with this I would be very thankful.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

How are you going to present this invoice to the customer?  It should be a printed report or at least a form (don't even think about printing a form) that can calculate the total in the form/report header/footer section or a report group header/footer simply by using a text box with a =Sum(price) kind of expression

I don't see where using a query to do that helps you, but if it is necessary, use a subquery in a calculated field or maybe a DSum expression.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

How are you going to present this invoice to the customer?  It should be a printed report or at least a form (don't even think about printing a form) that can calculate the total in the form/report header/footer section or a report group header/footer simply by using a text box with a =Sum(price) kind of expression

I don't see where using a query to do that helps you, but if it is necessary, use a subquery in a calculated field or maybe a DSum expression.

I was going to do both. I would add a button to the order form shown above that when clicked, takes the user to a form that shows the order details, as well as  the item prices and the total cost.There would be a button from there that takes the user to a report that shows the same details, but can be printed.

How would I use a form/report footer and textbox in this case? Would it be like creating the form, making acombo box that selects my order details, with other textboxs to be populated with the information bar the prices details, which use textboxes with the expression mentioned? If so, how would the expression work in case in consideration with the query I have already made for the first calculation?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Create an invoice form (continuous) based on your query without the calculated total field.  In the form's Footer section add a text box with the expression:

    =Sum([item cost] * quantity)

Do the same thing for the invoice report.  You might be able to get away without the invoice form by just opening the invoice report in PrintPreview (or, if it will always fit on one page or you use a continuous sheet kind of printer, maybe(?) using Report view).

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

First, This is one of the situations where the rule of relations databases against repeating data doesn't work. Price is a time sensitive value and you need to capture the price at the time of the order. So you need a unitcost field in your Order Items table. This can be filled in automatically by including the cost in the RowSource of the Item combo, then use the Column property to assign it to the Cost control. 

From there you can calculate the Extended cost by multiplying the quantity by the unitcost both on your form and in a query that feeds the invoice. 

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Microsoft Access MVP since 2007

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Just wanted to say thank you to everyone who provided help as it has been very helpful. I have been able to add the order invoice form into my database, which includes a subform used to view item details of the user's selected order.

Invoice form:

Subform:

The total price and total sum calculations have been performed within two of the subform's textboxes rather than in queries and it seems to work fine, although it won't display the values in pounds, but as pure numerical values. So apart from that issue of showing the prices as pounds, I now only need to create a report version of the invoice, which should be relatively easy I take it if I follow guides made by microsoft on this site.

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

To show the total in pounds, simply change the Format property of the textbox to "Currency". The currency symbol is just for display; it's not stored in the table.

John W. Vinson/MVP

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thank you to John Vinson, that advice solved the issue.

So, I'm getting there. I'm currently working on a bunch of reports to show data in a hard copy format.

However, an issue has arisen with the Invoice form. For whatever reason, when I enter an order with a customer who has already made a previous order, my invoice form is showing items from both of the customer's orders. Below is an example of this occurring:

Selecting the order number 1:

Note in the centre of the drop down table that appears from the combobox, between the collection time and customer forename, this column represents customer ID. As can be seen from the image, the order that I am selecting (layered in black) has customer ID number 3 assigned to it, as does order number 5. Below shows the subform after the user selects order 1 from the above combobox.

As can be seen from the above image, the subform shows two items, items 40 and 44. This is in error compared to the "Order Item" table, which clearly shows that there is only one item in the order:

I am unsure what the error is that is causing this issue, but I believe it has something to do with the query I am using for the invoice's subform. I will post images of the queries used for both the invoice and the subform, as well as for the design views of both forms, showing the properties of the order ID textboxes within each, in case they help provide information that could be helpful.

Invoice form query:

Invoice Subform query:

Invoice form design (with listed "Order No" combobox properties):



Invoice Subform design (with listed invisible "Order No" textbox's properties):

Again, thanks for all the help so far, it has helped a ton and it is getting this project closer to completion.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I'll have to look tomorrow after I've had some coffee (it's near midnight here). But... if your Query is linking on CustomerID you're seeing just what I would expect - all the records for that customer. If instead you want to see all the records for a particular Order you must instead link on the OrderID.

Note that posting screenshots of query designs is not ideal. Instead, if you're trying to get help with a Query, open it in SQL view (one of the options on the View button to the left of the ribbon) and copy and paste the SQL text into a message. It may look like Old Cuneiform Akkadian at this point, but it's the real query (the grid is just a tool to build SQL) and a lot of us are fluent in Old Akkadian :-{)

Similarly, a picture of a combo box is less informative than the SQL text of its RowSource query. This is one case where a few words are worth a thousand pictures!

John W. Vinson/MVP

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

I'll have to look tomorrow after I've had some coffee (it's near midnight here). But... if your Query is linking on CustomerID you're seeing just what I would expect - all the records for that customer. If instead you want to see all the records for a particular Order you must instead link on the OrderID.

Note that posting screenshots of query designs is not ideal. Instead, if you're trying to get help with a Query, open it in SQL view (one of the options on the View button to the left of the ribbon) and copy and paste the SQL text into a message. It may look like Old Cuneiform Akkadian at this point, but it's the real query (the grid is just a tool to build SQL) and a lot of us are fluent in Old Akkadian :-{)

Similarly, a picture of a combo box is less informative than the SQL text of its RowSource query. This is one case where a few words are worth a thousand pictures!

Ok. I'm still used to working in design and datasheet views, I haven't had much experience in using the SQL view. Here they are for both the Invoice query and subform query.

Invoice query SQL view:


Invoice Subform query SQL view:

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

If you want to produce an Invoice only for a specific Order, then you need to filter for that Order. what I would recommend is that you have a button on your Orders form to print an Invoice. The code behind that button should look like:

DoCmd.OpenReport "rptInvoice",acViewPreview,,"[OrderID] = " & Me.OrderID

Make sure you use your actual object names, but the idea is to only include Order records that match the currently displayed Order.

Hope this helps,
Scott<>
Blog: http://scottgem.wordpress.com
Microsoft Access MVP since 2007

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

* Please try a lower page number.

* Please enter only numbers.

* Please try a lower page number.

* Please enter only numbers.

 
 

Question Info


Last updated January 22, 2024 Views 4,777 Applies to: