Courses - Microsoft
Access 312 very strongly recommended|
Product Category Form, Filter, Zoom, Macro, Convert to VBA, Job Cost, Split DB
This course is valid for Access 2000 through 2003.
If you are using Access 2007 or 2010, you will still benefit from this course.
You will find that the concepts are the same, but there are cosmetic differences between the versions.
Order before 9/2/2016 to
get a FREE upgrade to our
Access 2010 version!
Click here for details
We'll begin by creating a Product Category
Master Form where we can see a list of product categories, and then
next to it a list of products in that category. These will both be in
subforms on the main Master form. When you click on a category, it will
update the other subform and show you just the products in that
category. Then we'll add the ProductF form below those, and the product
details will be shown down below - three forms in one.
Next, I want to be able to select a Category on
my order form, and then have the product combo box list filter its
results based on that selection by rewriting the SQL RowSource in
the combo box.
Next we'll see how to automatically Zoom
in to fields when they receive the focus (like a notes field) or if you
double-click on them. I'll teach you how to create a Macro and
then convert it into VBA code so you can figure out all kinds of
We'll see how to hide items on our Invoice - like
put cost-only products or services on an invoice and hide them
from the customer (but still calculate them in our Job Costs).
Our invoices are also looking really cool by this point.
Finally, we'll split the database intro
front-end and back-end files as we did back in Access 307, but this time
we'll walk through it in more detail, and I'll discuss the ramifications
of sharing your database with other users, and over a local area
ACCESS 313 - Course Outline
0. Introduction - 2:56
1. Product Category Master Form, Part 1 - 16:45
Making one subform control another with SQL RecordSource
Create the product category table: ProductCategoryT
Put a Product Category combo box on the Product Form
You can't put a subform in a continuous form
Make a second product list
Add ProductCategoryID to the Product Table
Creating a subform by dragging from the db window
Put two subforms side-by-side: Categories & Products
Filter the products based on the category I've selected
Give good names to each subform
Note that these are UNLINKED subforms - not linked to parent
Change OnCurrent event for Category subform
Set the RecordSource of the Product Subform to SQL
Showing all records - include "*" record and handle it in VB
Dim a String of characters (variable)
Sorting the Category List
2. Product Category Master Form, Part 2 - 8:48
Lock the product subform
AllowEdits, AllowDeletions, AllowAdditions: set all to NO
Do the same trick and show the product form on the bottom
Set the OnCurrent event for the product list to show product
Adding a ProductCategoryCombo to the product form
Set the combo's default value equal to the current category
Add an "Add Product" button
Adding Refresh buttons
3. Product Category Combo on Order Form - 6:59
Copy the ProductCategoryCombo from ProductF to OrderDetailF
When you pick a category, rewrite the SQL of the ProductCombo
ProductCategoryCombo AfterUpdate Event:
Set the ProductCombo.RowSource = SQL Statement
Deal with the "*" to show all records - special IF/THEN
Automatically open the ProductCombo when a category is picked
4. Auto Zoom to Notes Field - 6:07
Automatically zoom in when focus moves to notes field
OnGotFocus for Notes textbox
Discussion of RunCommand options in macros
Converting Macros to Modules
Create a macro and save it as a module to see VBA code
Editing the tab order, removing tab stops
Move the Zoom feature to the On Dbl Click event
5. Hidden Items on Invoice - 15:18
Items on invoices that you don't want the customer to see
Add ShowOnInvoice field to ProductT, OrderDetailT
Purpose of this to calculate job costs secretly
To hide item on invoice report, CANCEL the build section
Add ShowOnInvoice checkbox to detail section, make invisible
Go into BuildEvent
If Not ShowOnInvoice Then Cancel = 1, Exit the sub
Remember to add the same code to our other invoice report
6. Splitting the Database - 11:12
Compact the database
Split the database in two - covered in Access 307
Where your BACKEND database is located
Creating a new folder for your database - C:\Database
Move both database files to new folder
Open front-end database and it will ask for table locations
Load up the Linked Table Manager and point to Back End
Talk about setup on a network using a mapped drive or UNC path
7. Review - 4:43
Microsoft Access 313
Richard on 1/1/2008:
Access 313 covers making a Product Category table and form; a Master Form that shows all of the categories - you click on a category to show all of the products in that category on a second subform - then you click on the product to show the product details in a third subform; making a product category combo box on the order form that will filter the long list of products and automatically open it for us; automatic zoom into a field using VBA code; how to create a macro and then convert the macro to VBA code; how to hide specific items from your invoices so customers can't see them (if you need to add items for job costing); finally we'll split the database and go into database sharing in more detail.|
Twila Mitchell on 9/16/2008: What I really need is an easy way to print out a word document from vba. For instance, I have a policy that is over 60 pages long. Only page 1 and page 4 have information needed from my database so I would like to make a button that prints a report that is page 1 then will print a word document which will give me pages 2 and 3. Then I will print a report that is page 4 and finally, I will print a different word document that gives me pages 5 through the end. |
I can't find information anywhere that helps me. Can we include this in a future class?
Richard Rost on 9/17/2008: Twila, what you need is AUTOMATION. It's a way of controling one MS Office application from another. You can use Automation, for example, to open a Word document and print it from your Access database, or open Outlook and send an email. YES, I will be covering Automation in a future class.|
on 3/5/2009: Your lessons are very helpful for me,a beginner.|
Currecy$ is shown in UnitPrice of ProductCombo. How can I apply currency to a field in Combobox.
Richard Rost on 3/6/2009: Currency format in a combo box: The easiest thing to do is to format your field as CURRENCY type in a query and then use that query to feed your combo box. Or you can use the Format function to manually force it to Currency.|
Richard on 11/5/2009: Here is some information from Microsoft's web site on the benefits of splitting your database:|
Benefits of a split database
The benefits of a split database include the following:
* Improved performance The performance of the database usually improves significantly because only the data is sent across the network. In a shared database that is not split, the database objects themselves — tables, queries, forms, reports, macros and modules — are sent across the network, not just the data.
* Greater availability Because only the data is sent across the network, database transactions such as record edits are completed more quickly, which leaves the data more available to edit.
* Enhanced security If you store the back-end database on a computer that uses the NTFS file system, you can use NTFS security features to help protect your data. Because users access the back-end database by using linked tables, it is less likely that intruders can obtain unauthorized access to the data by stealing the front-end database or by posing as an authorized user. By default, Windows XP, Windows Vista, and Windows Server 2003 use the NTFS file system. If you are not sure what file system your file server uses, ask the system administrator. If you have administrator privileges on the file server, you can run the msinfo32 command to determine the file system yourself.
How do I use msinfo32 to check the file system?
1. Click the Start button, and then click Run.
2. In the Run dialog box, type msinfo32 and then click OK.
3. Under System Summary, click the plus symbol next to Components.
4. Under Components, click the plus symbol next to Storage, and then click Drives. The dialog box displays information about the available drives in the panel on the right.
* Improved reliability If a user encounters a problem and the database closes unexpectedly, any database file corruption is usually limited to the copy of the front-end database that the user had open. Because the user only accesses data in the back-end database by using linked tables, the back-end database file is much less likely to become corrupted.
* Flexible development environment Because each user works with a local copy of the front-end database, each user can independently develop queries, forms, reports, and other database objects without affecting other users. Similarly, you can develop and distribute a new version of the front-end database without disrupting access to the data that is stored in the back-end database.
Terry Hopper on 11/10/2009: When controlling a form from a form, can this be done with a list box as well? I would like to use a list box in place of the 'ProductCatagoryF' but have the same effect on the 'ProductListF'.|
Richard Rost on 11/11/2009: Terry, sure. You would just need to use an AfterUpdate event for the list box, and refer to the list box value.|
Terry Hopper on 11/11/2009: That is what I thought, but it's not working.|
Here is my code...
Forms!CustomerCenterF!CompanyInformationF.Form.RecordSource = "SELECT * FROM CompanyT WHERE CompanyID=" & CompanyID
What am I not getting?
I have the company list with the id hidden (0") and I am referencing the form by name & property of that form. Sorry, just don't get it.
Richard Rost on 11/13/2009: That should work. Make sure everything (form, fields, etc.) is spelled right. Aside from that, I'd have to look at your database to tell you for sure.|
Terry Hopper on 11/18/2009: Regarding the Zoom property. Can you make a button to Zoom into a field like notes but use the button as an option?|
Richard Rost on 11/19/2009: Terry, I don't understand your question. Do you mean the SHIFT-F2 Zoom feature? Yes, you can control that with a button. There is a VBA command for it: DoCmd.RunCommand acCmdZoomBox|
Terry Hopper on 12/4/2009: I have been working with this for weeks (11/14/09) and it still doesn't work. I have a EmployeeList box with EmployeeID, Active, FName & LName. The code is...|
Private Sub lstEmployees_AfterUpdate()
On Error Resume Next
Forms!frmEmployeeCenter!sfrmEmployeeContact.Form.RecordSource = _
"SELECT * FROM qryEmployees WHERE EmployeeID=" & EmployeeID
And I can't seem to figure it out. I have watched the video at least a half a dozen times and tried all different names for the fields to update.
Richard Rost on 12/14/2009: Terry, your code looks fine. I'd have to see your database to tell you for sure why it's not working. You might want to try putting the full name of the EmployeeID in the code to...|
...WHERE EmployeeID=" & Forms!MyForm!EmployeeID
If that doesn't work, let me know.
Or... is your listbox lstEmployees the field that contains your EmployeeID? If so, you need to say:
...WHERE EmployeeID=" & Forms!MyForm!lstEmployees
I'll bet that's it... unless EmployeeID is a separate field on that form.
Relja Koprolcec on 1/24/2013: Hey,I have just finisher 313 class and am ready for 314.Let me know if you already produced the alleged lesson.Regards Relja|
Reply from Richard Rost:
Nope. There is no 314. The next lesson in the series would be 320.
Relja K on 1/24/2013: Great! So I need to get along with record sets next couple of months!|
Reply from Richard Rost:
Yeah, it's not JUST recordsets. That's the main focus, but we build an order entry / invoicing system that's really cool. Lots of new techniques covered in it.
James Gray on 1/25/2013: Richard,|
Does the size limitation of Access databases include the data files or just the size of the front end?
Reply from Richard Rost:
The 2 GB limit is PER FILE (MDB or ACCDB). BUT, you can effectively increase that by moving tables to another file and then linking them in.
You may want to read these articles from the 599CD News: