Getting Started Quickly With Wizards Callahan Chapter 1 Creating a Database Using the Database Wizard n n Contacts database had several objects An application should be crafted so the user focuses on workflow not database objects q q n User Interface q q n n to a user forms and reports are the application with VBA code we can tailor the application to user s specs make information access processing easy user issues commands views results obtains feedback elements Switchboard Ribbon custom dialog boxes controls on forms Wizards written in VBA have a forms interface Practice Time q create Northwind 2007 accdb in CIS217 Data Files Others n we ll use later in the course 1 Entering Information Used Contact Types form to enter 3 types of contacts n Where were these Contact Types records stored n intuition suggests which Contact Types form property proves it q q View Records in the Contacts Form n To view enter modify delete Contact records q n a bound form A 2 page form with command buttons in Form Footer q q VBA code specifies what happens when a command button is clicked Page 2 uses a combo box that lists the Contact Types you entered n benefits of this combo box q q 2 Enhancing the Application n Adding an Object to Your Application q n used Report Wizard to create a new Contacts By City report Add the Report to the Switchboard Form q used Switchboard Manager to add a new command button on the Preview Reports switchboard page to expose Contacts By City report Adding a Command Button to a Form n Tried out existing Calls button to see how clicking a button can cause something to happen q q n what happened how was this engineered Added a command button to make it easier to add a new record to Contact table q q button s name AddRecord Command Button Wizard built code for command button s Click event 3 How Does the Button Work n Event q n a state condition or occurrence on an object for which you can define a response Event Procedure q q VBA code that is automatically executed when the event occurs Demo view the event procedure behind the button Private Sub AddRecord Click On Error GoTo Err AddRecord Click DoCmd GoToRecord acNewRec Exit AddRecord Click Exit Sub Err AddRecord Click MsgBox Err Description Resume Exit AddRecord Click End Sub Practice Time n n Open Artie s List mdb Modify frmRestaurant q q increase Form Footer s Height to 0 5 change Back Color property to match that of the Form Header use Control Wizard to place a new Add Record button named cmdAddRecord in Form Footer n q n q q save the form and test that it works use Control Wizard to place a new Print Record button named cmdPrintRecord in Form Footer n q save the form and test that it works use Control Wizard to place a new Save Record button named cmdSaveRecord in Form Footer save the form and test that it works size and align the buttons as illustrated Save frmRestaurant 4 Moving From Macros to Visual Basic n n n Used macros in CIS117 to automate tasks respond to user actions We ll study them later in CIS217 Visual Basic for Applications VBA q q Microsoft Office s native programming language more powerful and flexible than macros n n VBA s DoCmd object can implement most macro actions Access can convert macros to equivalent VBA procedures 5
View Full Document
Unlocking...