Creating invoice table using MS Access
BP210P Computer Applications in Pharmacy Practical
Citation: Chaudhari, M. (2024). MS access invoicing. Pharmacy Infoline. https://doi.org/10.5281/zenodo.10837712
MS Access invoicing
To fully understand the value of relational database you need to create a detailed system. In this practical you will setup an invoicing system for a computer mail order company, PC Direct, which sells computer peripherals through the mail. The invoice system will then be completed in the following steps. There are three main sections to the system, customers, products and the sales invoice.
In the creation of any database system you should do some careful planning. In general there are four steps that should undertake.
Steps
1: Decide how many tables you think you might need.
2: Decide how the tables will be related to one another.
3: List the fields in each table trying to avoid having the same field in more than one table. Decide which fields will be the PRIMARY KEY and FOREIGN KEY fields to link the tables.
Step 4: Decide what forms and/or reports (or printouts) are required
In the case of PC Direct an initial TABLE RELATIONSHIP diagram might be
The CUSTOMERS to INVOICE section of this structure forms a ONE TO MANY relationship. The one customer can have MANY invoices sent to them over time, but there will always be ONE customer on each invoice. So the customer table is the ONE side of the relationship and the INVOICE is the MANY side. We can set a relationship to link these two tables.
Problems:
There is a problem with the link between the INVOICE and the PRODUCTS tables.
The one invoice can contain many products and the one product can be included in many invoices. A relational database cannot cater for a MANY TO MANY relationship as you cannot set multiple PRIMARY or FOREIGN KEY fields in the one relationship.
A further problem exists, one invoice might contain a sale of 5 of a particular item, and the next invoice might contain a sale of 2 of the same item. The company needs a way of adding these sales so that it knows how many items it has sold. So this initial TABLE RELATIONSHIP will need modification.
Solutions:
The easiest solution to these problems is to add a table between INVOICE and PRODUCTS. This table can store every item sold by the company as a single record allowing the company to keep track of every item sold. The new table can also provide data to the INVOICE table.
The ONE invoice can have MANY items sold within it. The ONE product can be sold MANY times. By adding the LINE ITEMS table to the system a series of ONE TO MANY relationships is created and a relational database system can accommodate these.
The next step is to decide on the fields to be placed in each table. The following TABLE STRUCTURE diagram shows one possibility. Remember, we do not want to store data more than once (expect for PRIMARY KEY or FOREIGN KEY fields).
The PRIMARY KEY and FOREIGN KEY fields need to be considered. In the previous diagram you would have see that CUSTOMER ID is used to link the CUSTOMERS and INVOICE tables, INVOICE NO is used to link the INVOICE and LINE ITEMS tables and PRODUCT ID is used to link the LINE ITEMS tables and PRODUCT ID is used to link the LINE ITEMS and PRODUCTS table. The INVOICE table is not directly linked to the PRODUCTS table; it will obtain values from the PRODUCTS table via the LINE ITEMS table.
The final consideration in the planning is what reports will be required. The following diagram shows some of the reports that could be made from the various tables.
A Looking at the Tables
The database has 3 tables at the moment, CUSTOMER DETAILS which stores data about the company’s customers, LINE ITEMS which stores details of each product sold and PRODUCT DETAILS which stores a list of the products that the company markets
Close the CUSTOMER DETAILS table
Note: The LINE ITEMS table will record each line of the invoice. It will have two main purposes:
1. To list each product sold as a separate record so that the company can calculate monthly sales and carry out stock checks.
2. To provide product data to the invoice. If you look at the diagram at the centre of page 12-2 you will see that the PRODUCTS table is not directly connected to the INVOICE table so some data, such as Product Name and Retail price, will need to be linked to the LINE ITEMS table via a relationship to the PRODUCTS table so that the INVOICE can display them
Close the LINE ITEMS table.
Close the PRODUCT DETAILS table
Looking at the Forms
- Two forms have been prepared for you. The CUSTOMER SUB-FORM which displays the details from the CUSTOMER DETAILS table and the INVOICE MAIN FORM which you will need to complete.
- Close the CUSTOMER SUB-FORM form
- Close the INVOICE MAIN FORM.
Creating the invoice Table
An invoice table is required to store details every time an invoice is sent. This table simply records the INVOICE NUMBER, the CUSTOMER ID and the DATE of the purchase.
The links that we make to the other tables will display other tables will display other details such as product name and retail price
BP210P Computer Applications in Pharmacy Practical
- Design a questionnaire using a word processing package to gather information about a particular disease.
- Create an HTML web page to show personal information.
- Retrieve the information of a drug and its adverse effects using online tools
- Creating mailing labels Using Label Wizard, generating labels in MS WORD
- Create a database in MS Access to store the patient information with the required fields Using access
- Design a form in MS Access to view, add, delete and modify the patient record in the database
- Generating report and printing the report from the patient database
- Creating invoice table using MS Access
- Drug information storage and retrieval using MS Access
- Creating and working with queries in MS Access
- Exporting Tables, Queries, Forms and Reports to web pages
- Exporting Tables, Queries, Forms and Reports to XML pages