54
1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

Embed Size (px)

Citation preview

Page 1: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

1

All Powder Board and Ski

Microsoft Access WorkbookChapter 6: Forms and ReportsJerry PostCopyright © 2007

Page 2: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

2

Form Types

Style Style Description CategoryCustomer

Last NameFirst NamePhoneAddressCity

Ski Board Style

Sale

Customer Salesperson

ItemID Description Price Quantity Value

Main

Grid

Main and

Subform

Page 3: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

3

Customer Main Form

Combo box

Record navigation

Text boxLabel

Page 4: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

4

Action

ActionStart the form wizardSelect the Customer tableTransfer all columns to the right windowUse the Columnar layoutSelect a styleEnter a name for the form

Page 5: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

5

Main Form Wizard

Select table Select/transfer fields

Page 6: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

6

Form Design View

Toolbox to add controls

Properties to control objects

Right click to open control properties

Right click to open form properties

Switch to design or display view

Field List Box

Page 7: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

7

Data Source Properties

Record Source = Customer table

Form properties Control properties

Control Source = CustomerID column

Page 8: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

8

Action

ActionSwitch Customer form to design viewAdd a label as a form titleAdd a command buttonSelect Record Operation/Delete RecordAdd a command button to insert recordsRun the form and test the buttonsView/Tab Order and verify sequenceSave the form

Page 9: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

9

Adding Command Buttons

Page 10: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

10

Initial Grid Form

Page 11: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

11

Action

ActionCreate a new form with the wizardTable: SkiBoardStyleColumns: AllSelect the Datasheet layoutTest the form

Page 12: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

12

Grid Form Wizard

Datasheet style is simpler than Tabular

Tabular style has more design options

Page 13: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

13

Action

ActionSwitch to form Design viewDelete the box for CategoryAdd a combo boxSelect the first lookup optionChoose the ProductCategory tableChoose the Category and CategoryDescription columnsSet column widthsSelect the Category columnStore value into the Category columnRename the combo boxSet the tab orderRun the form and test the combo box

Page 14: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

14

Add a Combo Box

Delete the text box

Add a combo box

Page 15: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

15

Combo Box Role

SkiBoardStyle

Style Desc Category

Downhill Ski

ProductCategory

BoardBootsClothesElectronicGlassesSki

Display

Select

Page 16: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

16

Combo Box Runtime

Click the arrow

Select the item

Chosen value is transferred to form

Page 17: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

17

Action

ActionCreate a new form with the wizardSale table, all columnsCustomer table use name, phone, and e-mail columnsEmployee table, use the nameSaleItem table, all columns except SaleIDItemModel table, use Category, ModelID, and ListPriceFinish the wizard and test the form

Page 18: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

18

Main/Subform by Sale

Page 19: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

19

Initial Sale Form

Need combo box

Fix layout and sizing

Multiply price by quantity Calculate subtotal

Page 20: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

20

Action

ActionSwitch to Design viewReplace CustomerID, EmployeeID, and

PaymentMethod with combo boxesUse the Row Source property of the combo

boxes to set a sort orderSet tab order and run the form

Page 21: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

21

Initial Sale Form Improvements

Page 22: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

22

Most of the Sale Form

Display the subtotal

Page 23: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

23

Action

ActionOpen the sub form in Design viewInsert a combo box for the SKUAdd a text box to compute Value=QuantitySold*SalePriceAdd a text box to the footer to compute the subtotal:

=Sum(QuantitySold*SalePrice)Set tab orderTest the sub form calculationsOpen the main form in Design viewAdd subtotal text box and use the expression builder to copy the

subtotal value from the subfrom subtotalTest the form

Page 24: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

24

Expression Builder to Copy Subtotal

Open the Sale form

Select the subform

Double click the subtotal control

Formula to copy the subtotal value

Page 25: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

25

Final Sale Form

Page 26: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

26

Action

ActionCreate a new report with the wizardCustomer table, use all columnsSale table, use all columnsSaleItem table, use all columnsVerify the group breaksClick the Summary Options buttonCompute totals for the QuantityFinish the wizard and switch to design view

Page 27: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

27

Customizing Form Properties

Form properties

Text box

Page 28: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

28

Action

ActionMake a copy of the Customer form.In Design View, add a header.Drag the Customer title onto the header.Set the background color of the header to yellow.

Page 29: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

29

Create the Customer Sales Report

Select all columns from the Customer, Sale, and SaleItem tables

Customer break

Sale break

SaleItem detail

Page 30: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

30

Action

ActionCreate a new report with the wizard

Page 31: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

31

Report Summary Options

Select this button to calculate subtotals easily

Page 32: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

32

Summary Options

Page 33: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

33

Initial Report

Customer break

Sale break

SaleItem detail

Page 34: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

34

Report Design

Customer break

Sale break

SaleItem detail

Value textbox properties

Page 35: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

35

Action

ActionDelete some unnecessary columnsMove items around to improve the lookAdd a text box in the Detail section called Value

to compute [QuantitySold]*[SalePrice]Set currency formatEdit the Sum calculations to be

Sum([QuantitySold]*[SalePrice]Run the form and clean up the layout

Page 36: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

36

Final Design

Page break

Correct total

Page 37: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

37

Final Report (One Page)

Page 38: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

38

Action

ActionCreate a new query to total sales by customerSave the queryCreate a new report based on the queryFor the Customer group, set the Keep Together

property to Whole GroupRun the report

Page 39: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

39

Customer Totals Without Items

SELECT Customer.CustomerID, Customer.LastName, Customer.FirstName, Customer.Phone, Customer.EMail, Sale.SaleID, Sale.SaleDate, Sale.ShipCity, Sale.ShipState, Sum([SalePrice]*[QuantitySold]) AS [Value]

FROM (Customer INNER JOIN Sale ON Customer.CustomerID = Sale.CustomerID) INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleID

GROUP BY Customer.CustomerID, Customer.LastName, Customer.FirstName, Customer.Phone, Customer.EMail, Sale.SaleID, Sale.SaleDate, Sale.ShipCity, Sale.ShipState

ORDER BY Customer.LastName, Customer.FirstName;

Page 40: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

40

Sales Total Design

Page 41: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

41

Action

ActionCreate a simple report based on the Customer tableCreate a Sale sub-report from the Sale and SaleItem tables,

grouping it by SaleItem.Create a Rental sub-report from the Rental and RentalItem tablesOpen the Customer report in design viewDrag and drop the two sub-reports onto the Detail section of the

Customer reportUse properties of the sub-reports to set the Link Child and Link

Master Fields to CustomerIDRun the report

Page 42: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

42

Subreport: Sales and Rentals

Subreport properties

Link main customer report (master) to subreport (child)

Page 43: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

43

Subreport Display

Page 44: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

44

Action

ActionCreate a blank form in Design viewSet the properties to remove the scroll bars and

navigation buttonsAdd command buttons to open other forms (Form

Operations/Open Form) and reportsUse colors and graphics to make the form appealingRun the form and test all buttons

Page 45: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

45

Creating a Switchboard Form

Start in design view

Add command buttons

Open forms or reports

Page 46: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

46

Action

ActionChoose View/Toolbars/CustomizeOn the Toolbars tab create a new toolbarClick the Commands tabDrag the main form icon onto the toolbarAdd a Customers menu option and drag the

customer forms and reports onto itAdd the Help iconTest the toolbar

Page 47: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

47

Creating Toolbars and Menus

Create a new toolbar

Page 48: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

48

Toolbars and Menus

Drag commands onto the toolbar

Page 49: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

49

Action

ActionCreate at least three HTML help files for the All Powder forms using

an HTML editor or WordpadIf necessary, download and install the HTML Help workshopCreate a new project in the workshopAdd the HTML filesEdit the HTML files to add keywordsCreate the mapping file with a text editor and add it to the projectSet project options to build the TOC and index filesCompile and test the help fileEdit the database forms and add the help file name and ContentIDRun the form and press the F1 key to test the help files

Page 50: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

50

HTML Help

Form

Help File

AllPowder.chm

HTML Topic

HTML Topic

HTML Topic

HTML Topic

HTML Topic

HTML Topic

Properties:

Help File: AllPowder.chm

Help Context ID: 1

1 Topic A2 Topic B3 Topic C4 Topic D5 Topic E6 Topic F

compile

Page 51: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

51

HTML Help Files<Object type="application/x-oleobject" classid="clsid:1e2a7bd0-dab9-11d0-b93a-00c04fc99f9e"> <PARAM name="Keyword" value="Contents"> <PARAM name="Keyword" value="Introduction"> <PARAM name="Keyword" value="Start"> <PARAM name="Keyword" value="Management"></OBJECT><HTML><HEAD><TITLE>All Powder Board and Ski Shop</TITLE><LINK rel="stylesheet" type="text/css" href="Styles.css"></HEAD><BODY><H1>Introduction to the All Powder Board and Ski Shop</H1><TABLE><TR><TD><IMG SRC='BoardLogo1.gif' border='0'></TD><TD>All Powder Board and Ski Shop sells and rents snowboards and skis for all levels of riders and skiers.</TD></TR></TABLE><H2>The Board and Ski Shop</H2><UL><LI><A HREF=’Customers.html'>Customers</A></LI><LI><A HREF=’Sales.html'>Sales </A></LI></UL></BODY></HTML>

Page 52: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

52

Topics Map File

#define AllPowder 100

#define Customers 10000

#define Sales 20000

Page 53: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

53

Help Compiler and File

Page 54: 1 All Powder Board and Ski Microsoft Access Workbook Chapter 6: Forms and Reports Jerry Post Copyright © 2007

54

Help File on Access Form

File name

Topic number