00 creating the driving school database

Upload: opensource-betahafiz

Post on 14-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/30/2019 00 Creating the Driving School Database

    1/28

    A2 ICT Driving School Database

    /Creating the Driving School Database

    Part A - Design the tables.

    KGV ICT Dept. 169850738.doc 1

  • 7/30/2019 00 Creating the Driving School Database

    2/28

    A2 ICT Driving School Database

    KGV ICT Dept. 169850738.doc 2

  • 7/30/2019 00 Creating the Driving School Database

    3/28

    A2 ICT Driving School Database

    Part B - Set up relationships.

    Lookups will have set up relationships automatically.

    Set up other relationships.Enforce referential integrity.

    Part C - Enter test dataEnter the test data from Appendix A into separate tables through the database window.

    Enter 10-20 records. The validation checks can be tested while this is being done.In the test data for the date of the lesson in the lesson table ensure that you enter todays

    date for some of the lessons, as this is relevant to one of the queries to follow.

    KGV ICT Dept. 169850738.doc 3

  • 7/30/2019 00 Creating the Driving School Database

    4/28

    A2 ICT Driving School Database

    Part D - Set up the queries necessary to bring data together.

    Query

    Name

    Based on

    Table(s)

    Fields to Include Criteria Results

    1. qryLessons

    31 July

    tblLesson Lesson No

    StudentID

    InstructorIDDate

    Start Time

    Length of Lesson

    Date

    31/07/00

    Lesson

    Nos = 17,

    18, 20, 24

    2. qrySearch

    for Student

    tblStudent StudentID

    Surname

    Forename

    Tel No

    Surname

    Watson

    Student

    ID = 9

    3. qryInstructor Addresses

    tblInstructor InstructorIDSurname

    Forename

    Address1Address2

    Town

    Postcode

    Instructors1, 2, 3

    4. qryDates tblLesson Lesson no

    StudentIDInstructorID

    Date

    Collection point

    Date between

    30/07/00 and02/08/00

    >=#30/07/00#

    and

  • 7/30/2019 00 Creating the Driving School Database

    5/28

    A2 ICT Driving School Database

    Query

    Name

    Based on

    Table(s)

    Fields to Include Criteria Results

    6. qryOr tblStudent Surname

    Forename

    Address1Address2

    Town

    Postcode

    Mickleover

    or Littleover

    Student

    ID 3, 5

    7. qryToday tblLesson Lesson No

    StudentID

    InstructorIDDate

    Start Time

    Date =Date()

    ie Todaysdate

    Any

    records

    youentered

    with

    todaysdate

    8. qrySearchBy

    StudentID

    tblLesson Lesson No.StudentID

    Date

    Start time

    Length of Lesson

    StudentID

    [Enter the ID

    Number]

    ID = 1

    Lesson

    Nos 15,

    24, 32

    9. qrySearchon Lesson

    Date

    tblLesson StudentIDInstructorID

    Lesson No.

    DateStart time

    Length of LessonCollection point

    Lesson Type

    Date

    [Please enter

    the Date]

    02/08/00Lesson

    Nos

    25, 29, 30,31

    10. qryInstructor Lessons by

    Date

    tblLesson Lesson No.StudentID

    InstructorID

    DateStart Time

    Length of Lesson

    Collection Point

    Instructor ID

    [Enter the

    Instructor ID]

    Date

    [Enter theDate]

    ID = 2 on02/08/00

    Lesson

    Nos25, 30, 31

    11. qryLesson

    and names

    query

    tblLesson Lesson No

    StudentID

    InstructorIDDate

    Collection point

    KGV ICT Dept. 169850738.doc 5

  • 7/30/2019 00 Creating the Driving School Database

    6/28

    A2 ICT Driving School Database

    Query

    Name

    Based on

    Table(s)

    Fields to Include Criteria Results

    tblStudent

    Start time

    Surname

    12. qryInstructo

    r search

    tblLesson

    tblInstructor

    Lesson No

    StudentID

    InstructorID

    DateStart time

    Surname

    InstructorID

    1

    [Enter

    Instructor ID]

    Sort by date

    13. qryFull

    Details

    tblLesson

    tblInstructor

    tblStudent

    All fields

    Surname *Forename*

    Surname*

    Forename*

    * Re-namethese fields

    appropriately

    14. qryFullDetails By

    Date

    Base on qryFull Details Date

    [Please enter

    the date]

    Start timeascending

    15. qryNext

    Weeks

    Lessons

    Base on qryFull Details

    (Enter some lessons for next week

    in your in the lessons table)

    Between

    Date() and

    Date()+7

    16. qryLessonCost

    tblLesson

    tblLessonType

    tblInstructor

    tblStudent

    All fields

    Cost

    ForenameSurname

    ForenameSurname

    Address1

    Address2

    KGV ICT Dept. 169850738.doc 6

  • 7/30/2019 00 Creating the Driving School Database

    7/28

    A2 ICT Driving School Database

    Query

    Name

    Based on

    Table(s)

    Fields to Include Criteria Results

    Add a new

    calculated fieldTotalCost:[Length

    of Lesson]*[Cost]

    KGV ICT Dept. 169850738.doc 7

  • 7/30/2019 00 Creating the Driving School Database

    8/28

    A2 ICT Driving School Database

    Driving School Action Queries

    Make Table, Append and Delete Queries

    After a lesson has taken place, move the lesson to a table of old lessons tblOldLesson(Append query) and remove them from the Lesson table (Delete query)

    After a period of 1 year remove them from the old lesson table all together.

    Set up the table tblOldLesson with a Make Table query as follows

    NB This only needs running once to set the empty table up!!

    1. Create a query in design view based on tblLesson with all fields and with the

    criteria for Lesson No as 0 This avoids copying any records into tblOldLesson

    but creates the table structure.

    2. Run the query and check that tblOldLesson has been created properly.

    3. Make a copy oftblLesson because you are going to be changing dates and may

    want to use the existing data again. in the database window, tables section, click

    on tblLesson

    4. Click on the Copy button, then on the Paste button and set the table name to

    CopyoftblLessonOld and copy the Structure and the Data.

    5. Open tblLesson and change the dates as follows

    a. 01/08/00 to todays date

    b. 02/08/00 to tomorrows datec. 31/07/00 to yesterdays date

    d. 30/07/00 to a date exactly one year ago today

    6. Close tblLesson and create a copy of it in CopyoftblLessonNew

    7. Change the field type of Lesson No in tblOldLesson to Long Integer the

    Append query will not work if the field type is Autonumber!! Set this field as thekey field.

    8. Create a query qryOld Lesson Append based on tblLesson, all fields. Set the

    criteria in the Date field to

  • 7/30/2019 00 Creating the Driving School Database

    9/28

    A2 ICT Driving School Database

    10. Run the query and checktblOldLesson to see that the records have been added

    correctly

    Now set up the delete query to remove the lessons from tblLesson as follows;

    11. Create a query qryOldLessonDelete, based on tblLesson, all fields with thecriteria for the date field set to

  • 7/30/2019 00 Creating the Driving School Database

    10/28

    A2 ICT Driving School Database

    increase) and run the query.

    2. Check the price changes

    3. Try updating the prices by 1 [Cost]+1

    Totals Query

    1. We can total and count in a query Create a query qryLessonsData based on

    qryLesson Cost fields Lesson No and Cost.

    2. In design view, click on the Totals button on the toolbar to insert a Total row.Change the Lesson No entry in the Total row to Count and that for the Cost field

    to Sum.

    3. Test the query

    Exercise

    Use an Append query and two delete queries to archive students in a table

    tblOldStudents who have passed both theory and practical tests and do not require PassPlus

    KGV ICT Dept. 169850738.doc 10

  • 7/30/2019 00 Creating the Driving School Database

    11/28

    A2 ICT Driving School Database

    Part E - Set up forms and sub forms as necessary

    Set up the following forms frmStudent, using Autoform: Columnar, frmInstructorusing the Form Wizard and frmLessonType using using Autoform: Tabular

    We want to improve the appearance of the form by creating better navigationbuttons as shown below.

    1. Open frmStudent in design view

    2. Make sure that the Toolbox is showing and that the Control wizards tool isselected.

    3. Select the command button and drag out a button on the form.

    4. Select Record Operations in the wizard categories.

    5. Select Add New Record in the Actions List and click on Next.

    6. Choose Picture, Goto New2 (If you choose Text you can type in the textyou want) and click next.

    7. Call the button cmdAdd.

    8. Add extra buttons from the Record Navigation category with Actions

    a. Goto First Record

    b. Goto Previous record

    c. Goto Next record

    d. Goto Last record

    9. Add the close Form button from the Form Operations category

    10.Test that the buttons work correctly.

    11. Re-arrange the buttons to the order shown above

    12.Align them using Format, Align Top

    KGV ICT Dept. 169850738.doc 11

  • 7/30/2019 00 Creating the Driving School Database

    12/28

    A2 ICT Driving School Database

    13.Tidy up by using Format, Horizontal spacing, Make equal

    14.Make the buttons all the same size

    It is common practice to keep user buttons away from data entry areas.

    You are going to add a background to give a control panel effect.

    15.Add a Control Panel around the buttons as follows:-

    16.From the toolbox drag out a rectangle big enough to cover the buttons

    17.Set its colour to Light blue, set its Special effect to sunken

    18.Select the rectangle and use copy paste to make a copy of it. Make itslightly larger than the first and set its Special effect to Raised

    19.Position the smaller rectangle over the larger and centre the buttons onthe panel. If the buttons are hidden by the rectangles you may have to useFormat, Bring to Front.

    20.The system navigation buttons are now redundant so we can removethem and also change some other properties In design view, doubleclick on the form selector box (at the top left hand corner of the form). Thisdisplays the form properties window

    21.Set the following properties

    a. Caption Student details

    b. Scroll Bars none

    c. Record selectors No

    d. Navigation Buttons No

    e. Dividing Lines No

    f. Auto centre Yes

    g. Max min Buttons None

    22.Repeat for the other 3 forms you have created.

    KGV ICT Dept. 169850738.doc 12

  • 7/30/2019 00 Creating the Driving School Database

    13/28

    A2 ICT Driving School Database

    Creating the Lesson Booking form

    Select forms click on new. Select the form wizard and choose the Lesson Costquery.

    Select all of the fields - Next

    Select Columnar - Next

    Select Standard - Next

    Call the form frmLessonbooking and click on finish.

    We now need to customise the form to give it the same look and feel as theStudent and Instructor Forms

    Make the following changes:

    Move the fields down to make way for a heading

    Add a title Lessons in the same font, size and colour

    Edit the labels for Instructor and Student name control by removing thetext and underscore

    Add the control panel (not the buttons) by using copy and paste from one

    of the other forms

    Add the buttons using the wizard as before

    Set the form properties to the same as the other forms

    KGV ICT Dept. 169850738.doc 13

  • 7/30/2019 00 Creating the Driving School Database

    14/28

    A2 ICT Driving School Database

    Form with Tab Control

    Lesson and instructor Availability

    1. Ensure that qryFull Details contains the calculated fieldEnd Time: DateAdd(h,[Length of Lesson], [Start Time]) Format asShort Time

    2. Load frmLesson Booking in Design view3. Create a Tab control on the right hand side of the form you may need to

    enlarge the form and move some existing controls in order to make space4. The tab control will have 2 pages or tabs set the caption property of the

    first tab to Daily Timetable and of the second one to Weekly Timetable5. Click on the Daily Timetable tab and use the toolbox with the control

    wizard switched on to create a subform on the tab. Base the subform onqryFull Details fields Instructor ID, Student_Forename,Student_Surname, Date, Length of Lesson, Start Time and End Time

    6. You have to define your own linking fields InstructorID in both form andsubform and Date in both form and subform

    7. Call the subform sfrmDaily Timetable8. Save the form (as frmLesson Booking)9. Test the form it will need resizing repositioning and editing:-

    a. To change the column headings, in design view, click on each ofthe following text boxes in turn and edit the Name property asindicated Student_Forename to Forename, Student_Surname to

    Surname, Start Time to Start, End Time to End and Length ofLesson to Length

    b. Set the Text align property for Student_Forename,Student_Surname to Left and for Length of Lesson to Centre

    c. In form view adjust the width of the columns by dragging thecolumn dividers. Right click on the Instructor ID column and hide it.Change the form property Autoresize to No to keep your settings

    10.Ensure that qryNext Weeks Lessons includes the calculated field EndTime

    11.Now set up the Weekly Timetable Tab based on qryNext WeeksLessons with fields Instructor ID, Student_Forename, Student_Surname,Date, Length of Lesson, Start Time and End Time

    12.Link on the Instructor ID field only (not the date) and call the subformsfrmWeekly

    KGV ICT Dept. 169850738.doc 14

  • 7/30/2019 00 Creating the Driving School Database

    15/28

    A2 ICT Driving School Database

    13.Tidy up the form

    KGV ICT Dept. 169850738.doc 15

  • 7/30/2019 00 Creating the Driving School Database

    16/28

    A2 ICT Driving School Database

    Search and Sort Options

    Add an Extra Tab and Add Filters

    1. Use the form frmLesson Booking2. Add another tab to the tab control (insert menu Tab Control Page)3. Set its name to Search Options4. Close and save the form5. Create a new query, qryStudent Lesson, based on the Lesson table add

    all the fields from the table. Student ID is to be entered as a parameter bythe user

    6. Create a new macro, mcrSearch by Student, with Action Apply Filter argument Filter Name as qryStudent Lesson

    7. Open frmLesson Booking in design view and add a command button tothe search optionds tab to run the macro mcrSearch by Student

    8. Test the button scroll through the records to view just this studentslessons9. Set up another button to add a Filter by Date option based on qrySearch

    on Lesson Date. Call the macro mcrSearch by Date10.The filter needs removing afterit has been used Create a new macro

    mcrShow All Records It has one action ShowAllRecords Add acommand button to run the macro

    11.Test the buttons

    Add Sort Options

    1. Create a new macro mcrSort lesson i. Action GoToControl Argument Lesson Noii. Action RunCommand Argument Sort ascending

    2. Add a button to frmLesson Booking, Search options tab Sort by Lesson

    3. Add further buttons to Sort by instructor and sort by Student

    4. Test the form

    KGV ICT Dept. 169850738.doc 16

  • 7/30/2019 00 Creating the Driving School Database

    17/28

    A2 ICT Driving School Database

    Forgotten Student ID

    A student rings to book a lesson Operator clicks on Book a Lesson to openfrmLesson Booking

    If the student has forgotten their ID the operator needs to open frmStudent anduse the drop down to find the students ID

    The ID needs to be automatically transferred to frmLesson Booking when theoperator clicks a button

    1. Open frmLesson Booking in design view. Set up a button on the SearchOptions tab to Find a Student.

    2. Test that the button opens frmstudent

    3. Create the following macro mcrSelect student to paste the details intofrmLesson Booking

    4. Load frmStudent in design view and add a button labelled select studentto run the macro mcrSelect Student

    5. When you test this procedure, you will find that the system places the IDinto the booking form but you have to press enter to activate the form. Thiscan be avoided by creating amcro caleed mcrUpdate with the single action

    KGV ICT Dept. 169850738.doc 17

    Action Argument Value

    GoToControl Control Name Student ID

    RunCommand Command Copy

    Close Object Type Form

    Object Name frmStudent

    Open Form Form frmLessonBooking

    View Form

    GoToControl Control Name Student IDRunCommand Command Paste

  • 7/30/2019 00 Creating the Driving School Database

    18/28

    A2 ICT Driving School Database

    RunCommand with argument Refresh Page

    6. This needs to be attached to the On Change propert of the student ID fieldon frmLesson Booking.

    Cancel a Lesson

    1. Add a button Cancel booking to the Search options tab. Use the controlwizard to set up the delete operation use delete carefully!!

    Driving School Further Forms

    Add a combo Box to Enter Student Details

    1. Open frmStudent in design view

    2. Select the sex control and delete

    3. Ensure that the control wizard is switched on and put a combo box inplace of the deleted sex control

    4. In the wizard type in the values M and F and store the value in the Sexfield

    5. Change the label to sex and save the form.

    6. Test the form

    Add a combo box to look up student details

    1. Continue to work on frmStudent in design view

    2. Create room for a new control under the Students label at the top of theform

    3. Put a combo box in the space created and use the Find a record on myform based on a value I selected in my combo box

    4. Put the surname field into the selected fields and give the combo box thename Find record.

    NB. Look at properties of the combo box and see where the Source is set.

    KGV ICT Dept. 169850738.doc 18

  • 7/30/2019 00 Creating the Driving School Database

    19/28

    A2 ICT Driving School Database

    5. Save the form and test the combo box.

    Display the names in the combo box in alphabetical order

    1. In design view, select the Find record combo box

    2. Right click on the combo box and click on Properties select the data tab

    3. Click on the Row Source property and then on the to the right

    4. The SQL Statement Query window opens this looks like the querywindow. Set the surname field to ascending order.

    5. Close the window and save changes

    6. Test the combo box and close the form

    Create a Lesson Booking Form Data from more than one table

    1. Open qryLesson Cost (No 16 on queries sheet) This query brings

    together data from tblLesson, tblLessonType, tblInstructor and tblStudentwhich are needed when a booking is made.

    2. Close the query and create a new form based on qryLesson Cost as acolumnar form.

    3. Save it as frmLesson booking Form

    4. Switch to data view and find the option Size to Fit Form (this only shows ifthe form is not maximised), check and test the form, then close it.

    Subforms

    Lessons by Instructor subform by Method 1

    1. Use the Form Wizard to set up a new form based on tblInstructor fieldsInstructorID, Surname, Forename and on tblLesson fields StudentID,

    KGV ICT Dept. 169850738.doc 19

  • 7/30/2019 00 Creating the Driving School Database

    20/28

    A2 ICT Driving School Database

    Date, Start time, Collection point do NOT click next until you haveselected all these fields use Back if you missed some of them!

    2. View as a form with subform and View by Instructor

    3. Tabular layout naming the form frmInstructor Main and the subformsfrmLesson

    4. Check the form

    5. In design view click on the form selector of the main form (top left handcorner) and remove the scroll bars, Record selectors and Dividing lines

    6. Remove the Navigation buttons from the subform.

    7. Check the form

    Lessons by Student Subform by Method 2

    1. Set up frmStudentNew using Form Wizard based on tblStudent fields StudentID, Title, Forename, Surname, Address1, Address2,Town and Postcode

    2. Check the form

    3. Go into design view and rearrange the fields into 2 columns of 4 at thetop of the form

    4. From the toolbox click on the Subform/Subreport icon and drag out arectangle below the existing fields

    5. Use Existing Tables

    6. Select table - tblLesson fields Lesson no, Date, Start Time, Collectionpoint and Lesson type

    7. Leave the option at Choose from list Show Lesson for each record intblStudent using StudentID This is defining how the form andsubform are to be linked

    8. Call the subform sfrmLesson Details

    9. Save the form as frmStudent Lesson details

    KGV ICT Dept. 169850738.doc 20

  • 7/30/2019 00 Creating the Driving School Database

    21/28

    A2 ICT Driving School Database

    10.Look at the form in data view

    11. Make changes to the designs of the form and subform to improve theappearance Record selector, scroll bars, dividing lines

    Lessons by instructor Subform by Method 3

    1. Create a new form frmSTMain based on tblStudent fields StudentID,Surname and Forename Columnar form. Save and close it.

    2. Set up another form frmLT based on tblLesson fields Lesson No, Dateand Start Time a Tabular layout. Save and close it

    3. Open frmSTMain in design view

    4. Press F11 to view the database window and drag and drop the icon for thefrmLT onto the lower area of the open form frmSTMain

    5. View the properties of the subform (by right clicking on the border of thesubform not in the top left corner) and notice that the StudentID hasbeen identified as the linking field LinkChildFields and LinkMasterFieldsproperties

    More than one subform can be placed onto a main form if required!

    KGV ICT Dept. 169850738.doc 21

  • 7/30/2019 00 Creating the Driving School Database

    22/28

    A2 ICT Driving School Database

    Part F - Set up reports

    Instructor Report

    1. Produce a tabular report based on tblInstructor and including the fields InstructorID, Surname, Forename, Address1, Address2, Town andPostcode.

    2. Save as rptInstructor

    3. Set the orientation to Landscape

    4. In design view, change the title in the report header to Instructor Report

    5. Add the field Mobile No to the right of the Postcode field

    6. Increase the font size of the data to size 10 (currently size 8)

    7. Delete/edit the labels in the Page Header to read Instructor ID, Name,Address and Phone

    8. Rearrange the address fields so that they are arranged under the addressheading as Address1 Address2

    TownPostcode

    9. Move controls as necessary to tidy up the layout.

    Student Report

    1. Produce a tabular, landscape report rptStudent based on tblStudentincluding all fields.

    2. Ensure that the report fits into one page width

    Membership Card Report

    KGV ICT Dept. 169850738.doc 22

  • 7/30/2019 00 Creating the Driving School Database

    23/28

    A2 ICT Driving School Database

    1. Produce a columnar report rptMembership Card based on qrySearch byStudentID

    2. Change the border style for all controls to Transparent

    3. Left align the StudentID and Date of Birth controls

    4. Change the title in the report header to Membership Card

    5. Put the following message with border into the page footer (shift and enterwill force a new line)

    Instructors Timetable Report

    1. Use report wizard for the following report

    2. Base the report on qryFull Details by Date fields Student_Forename,Student_Surname, InstructorID, Start time and Length of Lesson.

    3. View the date By Lesson

    4. Add a grouping level Instructor ID

    5. Sort by Start Time

    6. Align Left1

    7. Corporate

    8. Call the report rptInstructors Timetable

    9. Test with the date 30/07/00

    10.The report should be grouped on Instructor but is unsatisfactory because

    a. The instructors names are not on the report

    b. The date is not on the report

    KGV ICT Dept. 169850738.doc 23

    Please keep this membership card safe and

    bring it with you to lessons

    Please inform us if any information is incorrect

  • 7/30/2019 00 Creating the Driving School Database

    24/28

    A2 ICT Driving School Database

    c. The column headings of Student_Forename and Student_Surnameare unsatisfactory

    11. In design view, alter the Student_Forename heading to read Name and

    delete the Student_Surname column heading

    12.Drag Date from the Field list onto the report header and format it to longDate. Delete the label for the Date field.

    13.Put the Instructor_Forename and Instructor_Surname onto the InstructorID Header. Delete the labels for these fields.

    14.Test the report with 30/07/00 as before

    15.To put each instructor onto a new page click on the Sorting and

    Grouping Icon, (or use View menu, Sorting and Grouping option)

    16.Click on the Instructor ID entry and change Group footer to Yes

    17.An Instructor ID footer has now appeared in design view set the propertyForce New Page to After section

    18.Check the report.

    Driving School Calculations in Reports

    Including a Total in a report

    1. Create a new report rptIncome based on qryLesson Cost with fields (inthis order) Instructor ID, Instructor_Forename, Instructor_Surname,Student_Forename, Student_Surname, Date and Total Cost.

    If the records are not grouped on instructor ID by default then addInstructor ID as a grouping level.

    Sort by Date and use Align Left1 layout.

    2. Test the report

    3. In design view, click on the sorting and grouping icon (or View menu,sorting and grouping option). Click on Instructor ID and change the GroupFooter property to Yes

    KGV ICT Dept. 169850738.doc 24

  • 7/30/2019 00 Creating the Driving School Database

    25/28

    A2 ICT Driving School Database

    4. Close the dialog box

    5. Put a new text box into the Instructor ID Footer area and set the followingproperties

    a. Control Source =Sum([TotalCost])

    b. Format Currency

    c. Font weight Bold

    Shift | F2 will open a zoom box if you need more room.

    6. Edit the text in the attached label box to Total

    7. Drag Instructor_Forename and Instructor_Surname from the Detail sectioninto the Instructor ID Header section

    8. Delete the Instructor_Forename and Instructor_Surname column headings

    9. Test the report

    KGV ICT Dept. 169850738.doc 25

  • 7/30/2019 00 Creating the Driving School Database

    26/28

    A2 ICT Driving School Database

    Count the records in a Report

    1. Add a new text box to the InstructorID Fooetr section to the left of the Totalboxes

    2. Set the Control Source property of the text box to =Count([TotalCost])

    3. Change the label to Number of Lessons

    4. Test the report

    5. Save the report

    Running totals in a Report

    1. Click on the Total Text box Control

    2. Set the Running Sum property to Over All

    3. Change the Total to running total

    Reports with no records

    1. Set up a macro mcrNo Data which displays a message box with themessage No data in this report.

    2. Open rptInstructors timetableand set the On No Data event in theproperties of the report to mcrNo Data

    3. Test the report

    4. Attach the mcrNo Data macro to the Membership Card report in the sameway

    KGV ICT Dept. 169850738.doc 26

  • 7/30/2019 00 Creating the Driving School Database

    27/28

    A2 ICT Driving School Database

    Part G - Automate with buttons / macros

    Driving School Macros

    Macro to open frmstudent

    1. In the database window click on Macros and new

    2. In the Action Column click on OpenForm

    3. Set the Action argument Form Name to frmStudent

    4. Close the macro window and save as mcrStudent

    5. Test the macro by running it

    6. Macros can have more than one action open mcrStudent in design view

    7. Add a second action GoToRecord with Argument New

    8. Save the macro and test it What effect does the new action have?

    9. The macro can open the form for adding only re-open mcrStudent indesign view and delete the GoToRecord Action

    10.Change the Data mode argument of the OpenForm action to Add

    11. Save the macro as mcrStudentAdd and test it.

    12.Set up macros mcrInstructor and mcrLesson to open frmInstructor andfrmLesson.

    Setting up a Message Box

    1. Create a new macro mcrAbout with Action MsgBox, Argument Created byyour name 2002 NB can be produced by typing ( c ) with nospaces!

    2. Set arguments

    KGV ICT Dept. 169850738.doc 27

  • 7/30/2019 00 Creating the Driving School Database

    28/28

    A2 ICT Driving School Database

    a. Beep Yes

    b. Type Information

    c. Title My Driving School

    3. Test the macro

    To set up a Menu as a Front end

    1. Create a new form in design view. Save the form as frmMenu

    2. Use the command button icon from the toolbox to set up buttons with

    appropriate messages to run the macros mcrStudent, mcrInstructor andmcrLesson Booking (Miscellaneous/run Macro option in the controlwizard)

    3. Set up a button to run mcrAbout

    4. Set up a button to quit the application (Application/Quit option in thecommand wizard)

    5. Set up buttons to run the reports rptInstructor, rptStudent, rptMembershipCard and rptInstructors timetable.

    6. A macro called AutoExec is run when the database is opened set this upas follows

    a. Action ArgumentEcho NoHourGlass YesRunCommand WindowHideOpenForm frmMenuRunCommand DocMaximise

    7. Test the autoexec macro NB F11 will display the database window