Chapter 5: Forms - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Chapter 5: Forms

Description:

Open Chap5.mdb (from your textbook CD) Create form by using Wizard ... If Not rs.EOF Then Me.Bookmark = rs.Bookmark. End Sub. Adding a Command Button ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 21
Provided by: conest
Category:

less

Transcript and Presenter's Notes

Title: Chapter 5: Forms


1
Chapter 5 Forms
2
Objectives
  • How to Create a Form
  • Single table forms
  • Form Properties
  • Understand Form Controls
  • Control Properties
  • Bound, Unbound, Calculated Controls
  • Command Button Wizards

3
Uses of Forms
  • Data Entry (focus of this chapter!)
  • Display and edit data
  • Application Flow
  • Navigate through the application
  • Custom Dialog Boxes
  • Messages to user
  • Printing Information
  • Hard copies of data-entry information

4
Using the Form Wizard
  • Open Chap5.mdb (from your textbook CD)
  • Create form by using Wizard
  • Select table (Table tblClients)
  • Select ALL fields (gtgt)
  • Select default Form Style (Standard)
  • Form title / form name
  • Naming Convention (Table B.1, Page 1264)
  • Begins with frm (e.g., frmClientsPractice)
  • No spaces in form name

5
Result of Using Wizard
  • Table set in Forms Record Source
  • E.g., tblClients
  • Form name shown in Database Window
  • Forms Caption (i.e., title) can be changed
  • Fields are added to Detail section as Text Boxes
    Note missing txt prefix

6
Building a Form from Scratch
  • Create a blank form
  • Set the forms Record Source
  • Use drop list for tables/ queries
  • Add fields to Detail section
  • Add header/footer section
  • Add controls to Header section
  • And more

7
Anatomy of a Form
  • Header and Footer sections
  • Doesnt change from record to record
  • Controls such as a lookup list
  • Command buttons, etc.
  • Detail section
  • Main section of form
  • Shows data from each record of the table or query
  • Controls such as Text boxes

8
Forms Design View
Form Selector
Header
Detail
9
Changing the Form Properties
  • Click Form Selector
  • Option Click gray area to the right of form
  • Display the Property Sheet
  • Shortcut F4
  • Set the Record Source
  • Set the Caption (for the Form Title)
  • Other properties Record Selectors Yes/No
  • Set to No for custom menu (ADO/Chapter 14)
  • More form properties Pages 169 - 176

10
Bound Controls (Text Box)
  • To get information from the user
  • Example ClientID field (in the detail section of
    frmClients)
  • Textbox Name txtClientID
  • Has a Control Source ClientID
  • i.e., txtClientID control is BOUND to the
    database changes to txtClientID will be saved to
    the database (tblClients.ClientID)

11
Bound Controls (Combo Box)
  • Example cboTermType
  • In the detail section of frmClients
  • Has a Control Source TermTypeID (fk)
  • Has a Row Source
  • Select TermTypeID from tblTerms

12
Other Controls
  • List Boxes
  • Similar to Combo box (Chapter 9)
  • Check Boxes
  • For Yes/No fields
  • Option Groups
  • For Option buttons (radio group)
  • Option Group Wizard
  • Details Pages 159 - 167
  • More Control Properties Pages 176 - 182

13
Adding Fields to Forms
  • Activate Field List
  • Drag and drop a field
  • Default Label attached to a Text Box
  • Typical changes
  • Other tab, set Name property
  • Change the name (prefix with txt, cbo, lst, etc.)
  • Morph foreign keys to Combo Box (Page 168)
  • Right-click, Change To, Combo Box
  • Data tab, set Row Source property, Bound column,
    Column Count, Column Width

14
Unbound Controls
  • Example cboSelectClient (Combo Box without a
    Control Source)
  • In the header section of frmClients
  • Does not have a Control Source
  • Data selected is not saved to Database

15
Adding an Unbound Control
  • Activate Toolbox (in Form Design Toolbar)
  • Activate Control Wizard (in Toolbox)
  • Add Combo Box (drag and drop to form)
  • Follow the Wizard
  • Set Name Property (e.g., cboSelectClient)
  • Set the sort order, etc.
  • Details in Page 198
  • Note Unbound control can also use expressions
    (See pages 183-184)

16
Finding a Record By Value
  • In cbos After Update event, click ellipsis
  • Copy the code to find the client record using the
    Value of cboSelectClient
  • Private Sub cboSelectClient_AfterUpdate()
  • ' Find the record that matches the control.
  • Dim rs As Recordset
  • Set rs Me.Recordset.Clone
  • rs.FindFirst "ClientID "
    Me.cboSelectClient.Value
  • If Not rs.EOF Then Me.Bookmark rs.Bookmark
  • End Sub

17
Adding a Command Button
  • Add Button (drag and drop to form)
  • Follow the Wizard
  • Form Operations, Open Form
  • Find Specific Data to Display
  • tblClients.ClientID tblProjects.ClientID
  • Details in Page 201
  • Notes
  • frmProjectss record source query has a parameter
    linked to frmClients
  • Note Code automatically generated by Wizard

18
Moving and Aligning Objects
  • Moving the controls
  • Use pointing finger to move textbox from label
  • Use hand cursor to move a control to another
    section
  • Menu Format Align Right
  • Also Tools Customize, Toolbar tab, check
    Alignment Sizing
  • Snap to Grid
  • To ignore feature CTRL Arrow Keys or Drag with
    Mouse

19
Selecting and Sizing, etc.
  • Multiple select SHIFT Left-Click
  • Useful to move a group of objects
  • Menu View Tab Order
  • Menu Format Size
  • To Fit, etc.
  • Details See Pages 153 - 158

20
Next Steps
  • Practice (Chap5.mdb solution in CD)
  • Designing the Clients Form
  • Designing the Projects Form
  • Adding a Command button
  • Link Clients and Project Forms
  • Textbook Pages 196 201
  • If youre new to Access, this is not easy.
  • You must try this exercise to understand this
    chapter!
Write a Comment
User Comments (0)
About PowerShow.com