Use MS Access 365 for Inventory Management |
Part 3: Creating Queries for Inventory Tracking and Analysis |
1. Introduction to Queries in MS Access |
1.1 What is a Query |
A query in MS Access is a tool used to retrieve, filter, calculate, and manipulate data stored in tables. Queries allow users to extract meaningful information from raw data without altering the underlying tables (unless using action queries). |

|
1.2 Importance of Queries in Inventory Management |
Queries are essential because they enable: |
1. Real-time stock tracking |
2. Inventory valuation |
3. Sales and purchase analysis |
4. Data validation |
5. Decision-making support |
Without queries, the database would simply store data without providing actionable insights. |

|
1.3 Types of Queries in MS Access |
MS Access supports several types of queries: |
1. Select Queries |
2. Parameter Queries |
3. Crosstab Queries |
4. Action Queries |
* Append |
* Update |
* Delete |
* Make-Table |
Each type serves a different purpose in inventory management. |

|
2. Creating Basic Select Queries |
2.1 Purpose of Select Queries |
Select queries are used to retrieve and display data based on specific criteria. |
2.2 Steps to Create a Select Query |
1. Open MS Access |
2. Go to “Create“Query Design3. Add relevant tables |
4. Select required fields |
5. Define criteria |
6. Run the query |
2.3 Example: Product List Query |
This query retrieves: |
1. Product name |
2. Category |
3. Supplier |
4. Price |
5. Stock quantity |
It helps users quickly view all available products. |
2.4 Sorting and Filtering Data |
You can: |
1. Sort by price (ascending/descending) |
2. Filter products by category |
3. Show only active products |

|
3. Calculated Fields in Queries |
3.1 What are Calculated Fields |
Calculated fields perform computations within a query. |
3.2 Example: Inventory Value Calculation |
Formula: |
InventoryValue = StockQuantity UnitPrice |
This helps determine the total value of stock. |
3.3 Creating Calculated Fields in Access |
Steps: |
1. Open query in Design View |
2. Add a new column |
3. Enter expression |
Example: |
TotalValue: [StockQuantity] * [UnitPrice] |
3.4 Use Cases |
1. Total inventory value |
2. Profit margins |
3. Cost calculations |

|
4. Filtering Data Using Criteria |
4.1 Using Criteria in Queries |
Criteria allow filtering records based on conditions. |
4.2 Examples |
1. Products with stock less than 10 |
2. Transactions within a date range |
3. Sales above a certain value |
4.3 Logical Operators |
1. AND |
2. OR |
3. NOT |
4.4 Example Query Conditions |
1. StockQuantity < 10 |
2. TransactionDate Between Date1 And Date2 |
3. Category = 'Electronics' |

|
5. Parameter Queries |
5.1 Purpose |
Parameter queries prompt users to input values at runtime. |
5.2 Example: Date Range Query |
The system asks: |
Enter Start Date |
Enter End Date |
Then displays transactions within that range. |
5.3 Creating Parameter Queries |
1. In criteria field, enter: |
[Enter Start Date] |
2. Repeat for end date |
5.4 Benefits |
1. Flexible reporting |
2. User-friendly |
3. Dynamic data filtering |

|
6. Aggregate Queries (Totals Queries) |
6.1 Purpose |
Aggregate queries summarize data. |
6.2 Functions Used |
1. SUM |
2. COUNT |
3. AVG |
4. MIN |
5. MAX |
6.3 Example: Total Stock per Product |
This query calculates: |
TotalQuantity = SUM of all transactions |
6.4 Grouping Data |
Group by: |
1. Product |
2. Category |
3. Supplier |

|
7. Inventory Stock Calculation Queries |
7.1 Concept of Stock Calculation |
Stock is calculated as: |
Total IN Total OUT |
7.2 Query Design |
1. Filter transactions by type (IN/OUT) |
2. Sum quantities |
3. Calculate net stock |
7.3 Example Fields |
1. TotalIn |
2. TotalOut |
3. CurrentStock |
7.4 Importance |
Provides: |
1. Accurate stock levels |
2. Real-time inventory tracking |

|
8. Joining Multiple Tables in Queries |
8.1 Purpose of Joins |
Joins combine data from multiple tables. |
8.2 Types of Joins |
1. Inner Join |
2. Left Join |
3. Right Join |
8.3 Example |
Join: |
Products + Suppliers + Categories |
Result: |
Complete product information view. |
8.4 Best Practices |
1. Use meaningful joins |
2. Avoid unnecessary tables |
3. Ensure relationships are correct |

|
9. Action Queries for Inventory Management |
9.1 Overview |
Action queries modify data. |
9.2 Types |
1. Append Query |
2. Update Query |
3. Delete Query |
4. Make-Table Query |
9.3 Append Query |
Used to: |
Add new records to a table. |
Example: |
Import new stock data. |
9.4 Update Query |
Used to: |
Modify existing records. |
Example: |
Update product prices. |
9.5 Delete Query |
Used to: |
Remove unwanted records. |
Example: |
Delete discontinued items. |
9.6 Make-Table Query |
Creates a new table from query results. |
Example: |
Backup inventory snapshot. |

|
10. Crosstab Queries for Analysis |
10.1 Purpose |
Crosstab queries summarize data in a matrix format. |
10.2 Example |
Rows: Products |
Columns: Months |
Values: Sales quantity |
10.3 Benefits |
1. Easy trend analysis |
2. Visual comparison |
3. Reporting support |

|
11. Query Optimization Techniques |
11.1 Reduce Data Load |
1. Select only necessary fields |
2. Apply filters early |
11.2 Use Indexes |
Indexed fields improve query speed. |
11.3 Avoid Complex Calculations |
Break large queries into smaller ones. |

|
12. Error Handling in Queries |
12.1 Common Errors |
1. Null values |
2. Division by zero |
3. Incorrect data types |
12.2 Handling Null Values |
Use: |
Nz() function |
Example: |
Nz([StockQuantity], 0) |

|
13. Creating Reusable Queries |
13.1 Benefits |
1. Save time |
2. Standardize logic |
3. Improve maintainability |
13.2 Naming Conventions |
Examples: |
1. qryProductList |
2. qryStockSummary |
3. qrySalesReport |

|
14. Security Considerations |
14.1 Restrict Sensitive Queries |
Limit access to: |
1. Cost data |
2. Supplier pricing |
14.2 Use Read-Only Queries |
Prevent accidental data changes. |

|
15. Practical Query Examples |
15.1 Low Stock Alert Query |
Criteria: |
StockQuantity < ReorderLevel |
15.2 Inventory Valuation Query |
Calculation: |
TotalValue = Quantity Cost |
15.3 Sales Summary Query |
Group by: |
1. Product |
2. Date |

|
16. Preparing for Forms and Reports |
Queries serve as the foundation for: |
1. Forms (data entry) |
2. Reports (analysis and printing) |

|
17. Summary of Part 3 |
In this section, we covered: |
1. Types of queries in MS Access |
2. Creating select and parameter queries |
3. Calculated and aggregate queries |
4. Inventory stock calculations |
5. Action queries and data manipulation |
6. Optimization and error handling |