599CD.com Access Calendar Updates   Collapse Menus
 
 
NEW Courses - Access Imaging, Excel 2007 Level 5 dismiss
 
   
 

What's New?  |  Courses  |  Theater  |  Demo  |  Tips  |  Blog  |  Forums  |  Search  |  Help  |  Order

 
What do you want to learn today? 
 
 
Courses - Microsoft Access 311
Description: Advanced Access
Running Time: 86 minutes
Pre-Requisites: Access 310 very strongly recommended
Versions:
We use Access XP in this course, but the lessons are valid for all versions of Access from 95 to 2003. There are cosmetic changes in Access 2007. Order before 3/13/2010 to get a FREE upgrade to our 2007 version when released!
 

Access 311 covers adding cost to our database so we can track net profit or loss for our sales. We'll also build a custom sales report and sales form for reporting. Finally, we'll create a form that has dynamically generated SQL to control what records and sorting are in the form.

First, I'd like to be able to figure out how much profit I'm making on each order by knowing the cost of my labors and materials. We'll start out by adding UnitCost info to our OrderDetailT and Order Subform. We'll add subtotals to the form as needed.

 

Next, we'll create a SalesReport query and report to show each order, what our cost is on that order, and what our net profit is.

 

Using our Sorting & Grouping levels and the Format() function, we'll create a custom format and breakdown for all of our sales by month.

 

We'll then create a simple form to set the limits (begin date and end date) for our sales report. Using the Forms ! FormName ! Field notation and the Between keyword to limit our sales query / report based on this information.

 

Next comes something that will add a whole new dimension to your form design... creating forms with a dynamic SQL statement controlling their records. In this case, we'll make our Order List form able to show quotes, invoices, paid invoices, unpaid invoices, and both quotes and invoices all by just selecting the option from a combo box. Our VBA code will construct an SQL statement which will update the records.

 

We'll also create a combo box to change which field our records are sorted by (company, name, amount due, order total, date, etc.) and a Sort A-to-Z or Z-to-A button to control ascending/descending sorts. This might sound easy, but we have to do it all using VBA code and events - take nothing for granted!

 

 


ACCESS 311 - Course Outline

0. Introduction - 2:42

1. Unit Cost on Orders - 13:16
Being able to calculate profit by knowing item costs
Adding UnitCost info to OrderDetailT
Creating an ExtendedCost field (UnitCost * Quantity)
Adding UnitCost and ExtCost to our OrderDetailF
Adding calculated totals to footer
Adding Cost fields to our Product Table
Get the product cost when a product is selected from ComboBox

2. Sales Report - 12:07
Creating a Sales Report with Cost & Profit
Add cost information to OrderListQ
Create the SalesReport Query and Report
Format() function to force numbers to show as currency

3. Sales Report & Form - 13:49
Adding totals to our Sales Report
Remember you can't put SUMs in your Page Footer
Create a Report Footer
Sort our Sales by Date - Sorting & Grouping Level
Group Header & Footer ON
Group On: Month
Format() Function: Format(OrderDate,"yyyy mmmm")
Criteria form to set begin date and end date for sales report
The Between keyword (remember me?)
[Date] is no good. Use Date()

4. Dynamic SQL Form 1 - 10:10
Clean up Customer List Form
Added Browse Customers and Add New Customer Buttons
DoCmd.GoToRecord acNewRec
Clean up Order List
Create an OrderList2Q so we can make more calculations
Add AmountDue information to OrderList form
Discuss what the Dynamic SQL Form is going to do

5. Dynamic SQL Form 2 - 14:44
Create a combo box with a list of options:
 - Show Invoices & Quotes
 - Show Quotes Only
 - Show Invoices Only
 - Show Paid Invoices Only
 - Show Unpaid Invoices Only
These are the options we want to see in our Order List Form
Set the default value for the combo box
Create an unbound text box to hold our SQL statement
Review of SQL Statements
SELECT Fields FROM Table WHERE Criteria ORDER BY Field
Create the BuildSQLStatement sub
Creating your own Private Sub
Set the form RecordSource equal to our SQL statement
Me.RecordSource = MySQL
Using VBA Code to build the SQL statement based on selection
Using a SELECT CASE statement instead of IF THEN statements
Creating another combo box for sorting:
 - Sort by Order Date
 - Sort by Company Name
 - Sort by Last Name
 - Sort by Order Total
 - Sort by Amount Due
Add another SELECT CASE to handle the ORDER BY clause

6. Dynamic SQL Form 3 - 17:07
Checking our Sort Combo Filter
Put a call to BuildSQLStatement in the SortCombo build event
Put a call to BuildSQLStatement in the form OnOpen event
DEFINITION - right click on a function or sub name to jump
Create our own Sort A to Z (ascending / descending) button
Capturing an image on the screen with Print-Screen
Drop that capture into Windows Paint
Cut out the buttons you want to "borrow"
Paste the buttons into your form.
Change the border style (raised, sunken)
Change the button names: SortAZ, SortZA
Make SortAZ visible, SortZA not visible
If the SortZA button is visible, add "DESC" to SQL Statement
Make OnClick events for each of these buttons
Change Enabled = YES for these buttons
"You can't hide a control that has the focus"
Shift the focus with DoCmd.GoToControl
Hide your SQL text box
Add buttons to browse orders, add new order
Change SortAZ and SortZA buttons to IMAGES not OLE objects

7. Review - 2:26


 

Huge Discounts Available
When you purchase multiple classes together
Huge savings up to 50% off! Order Now.
 

Student Interaction: Microsoft Access 311

Richard on 1/1/2008:  Access 311 covers adding COST to our product table and order details table so we can calculate job cost and net profit; dynamically generating SQL statements to control the records on a form; advanced sorting and grouping on reports; more with the Format() function; major overhaul to the OrderListF form.
Alan Hill on 1/11/2008: Some SQL's get pretty complicated. I found creating a query and switching to SQL mode, copying and pasting can be helpful. You did not cover that alternative. I thought the image AZ and ZA buttons was a neat trick. That was new to me. Thanks
Richard Rost on 1/12/2008: I believe I covered this in Access 202. I showed you the button that switches between DESIGN mode and DATASHEET mode also can show you the SQL of a query. You're right though - I should have mentioned it again when we started covering dynamic SQL for forms.
 Harry on 4/11/2009: Is there an advantage to joining a first and last name using the record source of a text box on a form vs creating a custom field in the underlying query? I tend to prefer the latter as it seems a little quicker in rendering (esp for continuous forms) but I'm not sure.
 Harry on 4/11/2009: Whatis the purpose of a colon after each case statement? I've never seen that done nor used it myself. I can see it works, but what does it do?
 Harry on 4/11/2009: How can one open a form using dynamic sql (the dynamic part I can figure, the open part gives me fits) and avoid docmd.openform which seems to grab all records and then filter them? As an aside, apart from increased network traffic in a multi user environment, the filters can be accidently messed with by the user causing no end of confusion. Any comments?
Richard Rost on 4/14/2009: Harry, both work just fine. I prefer the latter as well for continuous forms. For a single form, doing it on the form is OK, but the query is more efficient.
Richard Rost on 4/14/2009: Harry, the colon is a habit I picked up because (a) it's old school, and (b) it allows you to create a SINGLE-LINE case statement like this: case "A": msgbox "do stuff" case "B": msgbox "do other stuff" case "C": msgbox "do yet more stuff" And so on. You can't do this without the colon, so it just kinda stuck with me and I use it all the time.
Richard Rost on 4/14/2009: Harry, just don't specify a recordsource when you build the form. It will open blank. Then change the recordsource yourself in the OnOpen event to a single record with an SQL statement.
BRYAN binkerd on 6/5/2009: cool beans rick, you rock
Jane Hu on 7/31/2009: I see a VB code in the course: Private Sub CompanyName_DblClick(...) DoCmd OpenForm "CustomerF",,,"CustomerID=' & Cust.... Could you explain the use of ",,," in the code. Also I can't see the whole VB code. Could you also explain please. Thanks very much!
Richard Rost on 7/31/2009: Jane, there are extra parameters in there (additional options you can specify) that aren't important at this time. Don't worry about them. I'll cover them in future lessons.
David Leech on 9/28/2009: One of my favourite classes so far! I love that you decided to use the az za button for this. In my opinion the command buttons in access are pretty ugly,I anticipate using images alot more. much more fun :) Really liked all these lessons. really cool stuff
 
 

You may want to read these articles from the 599CD Blog:

 

 

Need Help
 
Do you have questions about Word, Excel, Access, Web Design, or computers in general? Just ask us anything you'd like. Click here for assistance.
 

Get Free Tips & Tricks
 

Join our mailing list today and get information on our Free Tips & Tricks Newsletter including free video tutorials, eBooks, live seminars, and more.

Email:
Name:
Type in the word to the left:
 
Your email will be kept 100% safe and will never be given to 3rd parties.
 


CLICK HERE for a FREE lesson



Order your first 599CD course now.
Your Satisfaction is Guaranteed!


Subscribe to our RSS FeedWhat's This?

599CD on Facebook  599CD on Twitter  Subscribe to RSS Feed  Add to Live Bookmarks  Add to My AOL  Add to MyYahoo  Add to Google Reader or Homepage    hide help

599CD Home   |   Learn More   |   What's New?   |   Contact Us   |   Free Demo   |   FAQs   |   Order Now   |   Affiliate Program   |   TechHelp   |   MYOLP   |   Jobs   |   Downloads   |   Handbooks  (Text)   |    Mailing List   |   Lost Passwords   |   Referral Program   |   Online Poll   |   Corporate, Educational, Government, Non-Profit Sales   |   Message Forums   |   Testimonials   |   Privacy Policy   |   Free Gift CDs   |   Tips & Tricks

 
 

What's New  |  Home  |  Courses  |  Demo  |  Learn More  |  Contact  |  Order