Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 4th, 2006, 10:42 AM
Authorized User
 
Join Date: Mar 2006
Posts: 83
Thanks: 1
Thanked 0 Times in 0 Posts
Default Problem creating drinks control database

Hello!

I am trying to build a cocktail drinks control database.....basically I have the following already:

One table (tblRecipeDefinition) which contains two fields - Cocktail Name and CocktailID (primary key).

Another table (tblRecipeIngredients) which contains five fields (IngredientID (primary key), Ingredient Name, Measure Unit, Quantity, and CocktailID (which is used to link to the first table - one-to-many relationship))).

Now...this is where I am having trouble....how would I be able to use these tables, so that each day, I can input the total quantity of cocktails that are sold in a restaurant or bar, and the database will calculate for me (and generate a report) that shows the total consumption of each INGREDIENT by the end of the day? I am not very good with Access or VBA so step by step would be highly appreciated! :)

Thank you very much!
 
Old May 5th, 2006, 10:28 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You will need a table to enter sales in that is also looks up to the tblRecipeDefinition table.

Are you keeping a tally outside of the database, and then entering in a total value for each day, or are you checking off each sale one by one in the database?

The table would be something like:

tblSales
SalesID - PK
SalesDate - Default = Date()
CocktailID - FK to tblRecipeDefinition
Quantity - Number field
(Options)
BartenderID - FK to tblBartender?

tbltblRecipeDefinition
(Options)
Price - currency - price charged per cocktail

tblRecipeIngredients
(Options)
Cost - currency - food cost per ingredient qty

tblBartender
PK
LName - text
FName - text
etc
Salary - currency

These last fields and tables will allow you to do better cost accounting, and also see what each bartender is making you, and costing you.

Then you could do a query to multiply the total number of each cocktail sold by the ingredients in the tblRecipeIngredients table, how much cost there was associated with prices charged, etc, etc.

Anyway, if you create this first table, and then a query or queries, you can get this info out of this structure.

HTH

mmcdonal
 
Old May 5th, 2006, 07:53 PM
Authorized User
 
Join Date: Mar 2006
Posts: 83
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hello and thank you for your reply!

I will try your suggestions in the morning and let you know my results. Yes...basically the sales are being generated as they are entered in the POS. So at the end of the day, I print out a sales reports (i.e. total number of each drink that are sold during the day) and I intend to enter them into the Access database that I am trying to create so it gives me the ingredient consumption based on the recipe definition table.

Well..I will try in the morning and I will let you know.

Thank you! :)
 
Old May 5th, 2006, 07:56 PM
Authorized User
 
Join Date: Mar 2006
Posts: 83
Thanks: 1
Thanked 0 Times in 0 Posts
Default

What exactly do you mean by FK and PK? And what type of query would I try to create? A select? Append?

Thanks! :)
 
Old May 8th, 2006, 06:27 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

PK = Primary Key - this is the PK for the table. For example, in the tblRecipeIngredients table, IngredientID is the PK.

FK = Foreign Key - this is a look up field and takes the numeric PK value from the table it is looking up to. For example, in the tblRecipeIngredients table, CocktailID is an FK.

There is only one PK per table, but there can be many FK's per table. If a field is an FK, you should index that field as well.

mmcdonal
 
Old August 5th, 2006, 09:33 AM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please help. I am trying to build a similar cocktail database but cannot seem to identify the correct tables to use. I am a real beginner with Access so any help would be greatly appreciated.






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem: Creating the Example Database dcr BOOK: Beginning SQL 1 October 11th, 2007 07:56 AM
Creating a new control Bhattachan ASP.NET 2.0 Basics 0 August 12th, 2007 11:07 AM
problem i creating my own tool bar control in c# ch_faf General .NET 1 July 29th, 2004 07:29 AM
problem creating database nusrati MySQL 15 July 6th, 2004 10:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.