A More Advanced Database Illustration Access 2010



Similar documents
Microsoft Access 2010 handout

Instructions for Creating Silly Survey Database

MS Access Lab 2. Topic: Tables

Introduction to Microsoft Access 2013

Access 2007 Creating Forms Table of Contents

Introduction to Microsoft Access 2010

Microsoft Access 2007 Introduction

Microsoft Access 2010 Part 1: Introduction to Access

Microsoft Access Introduction

How to set up a database in Microsoft Access

Microsoft Access Basics

Introduction to Microsoft Access 2003

Microsoft Access 2010 Overview of Basics

Lab 2: MS ACCESS Tables

Access I Tables, Queries, Forms, Reports. Lourdes Day, Technology Specialist, FDLRS Sunrise

User Services. Microsoft Access 2003 II. Use the new Microsoft

MICROSOFT ACCESS A. CREATING A DATABASE B. CREATING TABLES IN A DATABASE

Creating a Form. A form is something that is created allowing users to enter information in a more visual manner than a datasheet view.

IN THIS PROJECT, YOU LEARN HOW TO

Creating a Database in Access

Access NAMES Computerized Database


Introduction to. Microsoft Access Practicals

Database File. Table. Field. Datatype. Value. Department of Computer and Mathematical Sciences

Business Objects Version 5 : Introduction

Microsoft Access 2007 Module 1

Basic Microsoft Excel 2007

Utilizing Microsoft Access Forms and Reports

Microsoft Office Access 2007 Basics

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

MICROSOFT ACCESS 2003 TUTORIAL

Task Force on Technology / EXCEL

Using an Access Database

Microsoft Access 2000

MICROSOFT OUTLOOK 2010 WORK WITH CONTACTS

Table and field properties Tables and fields also have properties that you can set to control their characteristics or behavior.

MS Access. Microsoft Access is a relational database management system for windows. Using this package, following tasks can be performed.

MICROSOFT ACCESS 2007 BOOK 2

MICROSOFT ACCESS STEP BY STEP GUIDE

Create a New Database in Access 2010

Using Microsoft Access

Getting Started with Excel Table of Contents

Creating a Database using Access 2007

Microsoft Access 2010

Creating tables in Microsoft Access 2007

User Services. Intermediate Microsoft Access. Use the new Microsoft Access. Getting Help. Instructors OBJECTIVES. July 2009

Appendix A How to create a data-sharing lab

Microsoft Access 2007

Creating a Database Using Access 2003 for Windows 2000/Me/XP

Using Microsoft Access Databases

Intellect Platform - Tables and Templates Basic Document Management System - A101

Writer Guide. Chapter 15 Using Forms in Writer

Excel 2003 Tutorial I

Business Objects. Report Writing - CMS Net and CCS Claims

A database is a collection of data organised in a manner that allows access, retrieval, and use of that data.

Intro to Excel spreadsheets

Crystal Reports Payroll Exercise

INTRODUCTION TO MICROSOFT ACCESS MINIMAL MANUAL

How to make a line graph using Excel 2007

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

PROJECT ON MICROSOFT ACCESS (HOME TAB AND EXTERNAL DATA TAB) SUBMITTED BY: SUBMITTED TO: NAME: ROLL NO: REGN NO: BATCH:

Consider the possible problems with storing the following data in a spreadsheet:

Excel 2003 A Beginners Guide

Module One: Getting Started Opening Outlook Setting Up Outlook for the First Time Understanding the Interface...

4. The Third Stage In Designing A Database Is When We Analyze Our Tables More Closely And Create A Between Tables

BUSINESS OBJECTS XI WEB INTELLIGENCE

Introduction to Microsoft Office Access 2010

Chapter 15 Using Forms in Writer

Use Find & Replace Commands under Home tab to search and replace data.

Microsoft Access 2010: Basics & Database Fundamentals

SonicWALL GMS Custom Reports

Excel 2007 A Beginners Guide

Creating and Using Databases with Microsoft Access

Access Database Design

Access Creating Databases - Fundamentals

Word 2007: Basics Learning Guide

Introduction to Microsoft Access 2007

Access II 2007 Workshop

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

Access 2010 Intermediate Skills

Access Queries (Office 2003)

MS Word 2007 practical notes

Microsoft Using an Existing Database Amarillo College Revision Date: July 30, 2008

Instructions for Formatting MLA Style Papers in Microsoft Word 2010

Microsoft Access XP Session 1 Week 8

Basic Excel Handbook

EXCEL PIVOT TABLE David Geffen School of Medicine, UCLA Dean s Office Oct 2002

Drawing a histogram using Excel

Using Microsoft Word. Working With Objects

In this session, we will explain some of the basics of word processing. 1. Start Microsoft Word 11. Edit the Document cut & move

PA Payroll Exercise for Intermediate Excel

Introduction to Microsoft Access XP

Writer Guide. Chapter 15 Using Forms in Writer

Learning Services IT Guide. Access 2013

ECDL. European Computer Driving Licence. Database Software BCS ITQ Level 1. Syllabus Version 1.0

BID2WIN Workshop. Advanced Report Writing

Access Using Access

Lab Manual. Databases. Microsoft Access. Peeking into Computer Science Access Lab manual

Microsoft Access 2013 An Intermediate Guide (Level 2)

Transcription:

A More Advanced Database Illustration Access 2010 3.1 Introduction and Checklist This illustration is taken from a form designed for data abstraction from medical records of women diagnosed with breast atypia. The form is intended to collect information to determine risk for developing breast cancer using the Gail Risk, a scale that rates risk based upon pregnancy and breastfeeding history along with race, ethnicity and menstrual history. The data abstraction form is shown on page 4. A completed MS Access database for data entry of data collected on this form consists of tables, forms, combo boxes, macros and modules. The following chart is an orientation to this jargon. MS Access Database Elements Table A table in Access is what we think of as a spreadsheet containing the actual data Form You can create an Access form that looks the same or nearly the same as your data collection instrument (the paper form). LookupTable, Combo box, combo drop function: Providing a drop down list for the user to use during data entry is a 3 step process: (1) create a table containing response list and codes a lookup table (2) create a combo box; and (3) create a macro that instructs MS Access to open the list automatically when the field is entered. Module with combo box function: This is an instruction to MS Access that tells MS Access to provide a drop down menu to the user when he/she is doing data entry. Macro to maximize: This is an instruction to MS Access that tells MS Access to maximize the form for the user so that it fills the screen when the form is opened. Macro to observe skip patterns: This is an instruction to MS Access to skip the user to the appropriate next query when a skip is desired. MS Access 2010 Example V2.Doc - 1 -

Checklist for MS Access Database Development a. Create a CODE SHEET: Identify variable (field) names that are associated with the each question on the data collection instrument b. Identify the variables for which drop down lists are desired. Identify the contents of the drop down lists themselves, too. c. Identify the variables for which skip patterns are desired. Identify the destinations the skip-to variables, also. d. Using a through c above, make a list of the lookup tables, macros and modules that are desired. e. Create the table that will contain the actual data. For now, these will be empty shells, with no data. Data entry to populate these tables will come later. f. Create the lookup tables that are needed to produce the drop down lists. g. Create the data entry form. h. Modify the design of the data entry form for readability as desired. i. Create the drop down menu utilities. These are the combo boxes. j. Edit your form to ensure data entry will proceed in the correct order. k. Make other formatting changes, as needed, to improve the appearance of your form. l. Create a module with combo box function. Name it module1. m. Create the a macro to maximize the form. n. Create the skip pattern utilities. These are also macros. o. Apply the module, combodrop function, and macros. MS Access 2010 Example V2.Doc - 2 -

Gail Risk Example This example illustrates a form with date, numeric and text responses. The completed Microsoft Access database for this example consists of 1 module, 5 tables, 1 form and 5 macros. The 5 tables include a main table to store the data (tblgail) plus 4 additional lookup tables that provide drop down data entry choices and associated codes. (These tables are called tblyesno, tblmenop, tblashken, and tblrace). Fig 1: Microsoft Access Database Tables for Gail Risk Data a. Create a CODE SHEET and Coding Manual: Code Sheet: Identify variable (field) names that are associated with the each question on the data collection instrument. Coding Manual: Specify data type and codes or range of values for each field. To create a code sheet, annotate a blank copy of the data collection instrument with the variable names that you have selected. An example of this follows. Page 4 shows the original paper data collection form. Page 5 is the code sheet, an annotated form showing the variable names associated with each question. Pages 6-7 show the coding manual or data dictionary, that spells out details of type of data and codes for each field to be defined. Have this in hand when you sit down to create your data table. MS Access 2010 Example V2.Doc - 3 -

Breast Cancer Example Form Original MS Access 2010 Example V2.Doc - 4 -

Breast Cancer Code Sheet Data Collection Form Annotated with Variable Names MS Access 2010 Example V2.Doc - 5 -

Coding Manual or Data Dictionary for Gail Risk Data Question Variable Name Data Type / Codes Description ID IDNUM Numeric, 3-digit Unique Study Identifier Range 1-999 BCP Numeric 0 No Patient from Comprehensive Breast Center 1 Yes 9 Unknown Q1 DOB Date in MM/DD/YYY Date of Birth Q2 DOP Date in MM/DD/YYY Date of Procedure Q3 AGE_ATYP Numeric, 2-digit Age at diagnosis of atypia Q4 MENARCHE Numeric, 2-digit Age at Menarche 99 Unknown Q5 GRAVID Numeric, 2-digit Number of times pregnant 99 Unknown Q6 PARITY Numeric, 2-digit Number of live births 99 Unknown Q7 AGE_FLB Numeric, 2-digit Age at first live birth 99 Unknown, Not applicable Q8 NUMBIOPS Numeric, 2-digit 99 Unknown Number of biopsies, including current one Q9 NUM1STDEG Numeric, 2-digit 99 Unknown Number of 1 st degree female relatives with breast cancer Q10 NUM2NDDEG Numeric, 2-digit Number of 2 nd degree Q11 LMP_MON LMP_DAY LMP_YR 99 Unknown Numeric 2- or 4-digit 99 or 9999 unknown Q12 MENSTAT Numeric, 1-digit 1 - Premenopausal 2 - Perimenopausal 3 - Postmenopausal 9 - UNKNOWN Q13 BRSTFEED Numeric, 1-digit 0 - No 1 - Yes 9 - UNKNOWN Q14 HRT Numeric, 1-digit 0 - No 1 - Yes 9 - UNKNOWN Q15 NSAID Numeric, 1-digit 0 - No 1 - Yes 9 - UNKNOWN relatives with breast cancer Month, Day and Year fields for date of Last Menstrual Period Menopausal Status History of Breastfeeding History of Hormone Replacement Therapy Current Non-steroidal Anti- Inflammatory Drug use MS Access 2010 Example V2.Doc - 6 -

Coding Manual or Data Dictionary for Gail Risk Data - continued Question Variable Name Data Type / Codes Description Q16 ASHKENAZI Numeric, 1-digit Ethnic Ancestry on list 0 - No 1 - Ashkenazi Jewish 2 - Dutch 3 - Icelandic 4 - French Canadian 9 - UNKNOWN Q17 HISPANIC Numeric, 1-digit Hispanic or Latina 0 - No 1 - Yes 9 - UNKNOWN Q18 RACE Numeric, 1-digit Racial Background 1 - White 2 - Black/African Amer 3 - Asian 4 - Pacific Islander 5 - Native Amer. 6 - Multiracial 7 - Other 9 - UNKNOWN Q19 ETHNICITY Text, 20 characters Specify other race/ethnicity Tips (1) Regarding date variables: When exact dates are known they can be developed as date fields in the software program eg. Date of Birth and Date of Procedure. However, if there is a possibility that the full date may not be recorded, such as the day or month part of Q11. Date of Last Menstrual Period then the date variable should be defined as 3 separate fields for month (LMP_MON), day (LMP_DAY) and year (LMP_YR). In a later step in data processing these can be combined to create dates and estimate durations as needed. (2) Regarding unknown as response: Some codes are provided on the form, eg. ENTER 99 IF UNKNOWN Others are left up to the database designer to determine, eg: NO=0 YES=1 UNKNOWN=9, or the responses for Q12, Q16 and Q18. Defining these codes is part of the work of designing the codebook and database. The codes for these responses are stored in the additional tables known as lookup tables. The purpose of a lookup table is to match codes to their meaning. This can be almost trivial, as in 0=No, 1=Yes, 9=Unknown, or more complex, as in a system matching billing codes to items billed which can be an enormous table. MS Access 2010 Example V2.Doc - 7 -

b. Identify the variables for which drop down lists are desired. Identify the contents of the drop down lists themselves, too. That is, identify those fields where you wish to define a drop down list for data entry, and specify the codes and descriptions that will appear on screen in the drop down menu. Question Variable Name Drop Down Menu Table in Access Q12 MENSTAT 1 - Premenopausal Tblmenop 2 - Perimenopausal 3 - Postmenopausal 9 - UNKNOWN Q13 BRSTFEED 0 - No Tblyesno Q14 Q15 Q17 HRT NSAID HISPANIC 1 - Yes 9 - UNKNOWN Q16 ASHKENAZI 0 - No Tblashken 1 - Ashkenazi Jewish 2 - Dutch 3 - Icelandic 4 - French Canadian 9 - UNKNOWN Q18 RACE 1 - White 2 - Black/African Amer 3 - Asian 4 - Pacific Islander 5 - Native Amer. 6 - Multiracial 7 - Other 9 - UNKNOWN tblrace c. Identify the variables for which skip patterns are desired. Identify the destinations the fields you will skip to, and automatic fill-in values. Response Prompting Skip Skip to destination The bypassed items are: The bypassed variables and assigned values are: Q5: Gravid = 0 Q8: NUMBIOPS Q6 Q7 PARITY = 0 AGE_FLB = 99 (unknown) Q6: Parity = 0 Q8: NUMBIOPS Q7 AGE_FLB = 99 (unknown) Q6: Parity = 0 Q14: HRT Q13 BRSTFEED = 0 MS Access 2010 Example V2.Doc - 8 -

d. Using a through c above, make a list of the lookup tables, macros and modules that are desired. 5 Tables are needed: 1. Table for data (Name: tblgail) 4 Lookup Tables for drop down menus: 2. Table for MENSTAT (Name: tblmenop) 3. Table for YESNO (Name: tblyesno) 4. Table for ASHKENAZI (Name: tblashken) 5. Table for RACE (Name: tblrace) 1 Form is needed: Form for data entry (Name: frmgail) 1 Module is needed: Module to implement drop down menu using combo drop function (Name: module1) 4 Macros are needed: 1. Macro to maximize appearance of the form (Name: maximize) 2. Macro to skip from Q5 to Q8 (Name: skpq5toq8) 3. Macro to skip from Q6 to Q8 (Name: skpq6toq8) 4. Macro to skip Q13 altogether (Name: skpq13frmq5) MS Access 2010 Example V2.Doc - 9 -

e. Create the table that will contain the actual data. For now, this will be an empty shell, with no data. Data entry to populate will come later. Note In this example, there is just 1 table that will contain the actual data. Steps in Creating an MS Access Table 1) Launch Access and open a new data base Select File > New At right, click: Blank Database Under File Name: Name the file Gail_Risk.accdb At right, click on the folder icon Specify where to store your data base Click CREATE. Or, press the ENTER key. 2) Create your main table which will store your data tblgail CREATE > Table Design Fig 1 3) Using Design View a. Specify Data Type and Field Properties for all your variables. (3.1) ID Variable: Enter variable names in the column labeled Field Name starting with the key variable. The key variable is the linking variable if the database contains several tables of data. In this case the key variable is IDNUM. a) Type IDNUM into the Field Name column, b) Tab over to the Data type column and select Number from the list c) Enter the details about the variable in the Field Properties pane at the bottom of the screen (Fig 2) Fig 2: Field Properties for ID variable Note - At Required change No to Yes use required only for ABSOLUTELY required data MS Access 2010 Example V2.Doc - 10 -

d) Choose Long Integer for the field size best for use with the key variable e) Select the key icon on the task bar to indicate that this variable is the primary key Fig 3: Task bar showing key icon f) Select 0 for decimal places g) Type ID for the caption h) Check that the Default value is blank i) Select Yes in the Required Field j) Type ID: as the Caption k) Type Unique Study ID number in the Description column Other variables: Enter details for all the other variables in the table and field properties panes, choosing Date/Time as the field type for DOB and DOP, Text as the field type for ETHNICITY, and Number as the field type for all other variables. Fig 4: List of all variables with Data Type MS Access 2010 Example V2.Doc - 11 -

Summary: For the numeric variables that will hold only codes (BCP,MENSTAT, BRSTFEED, HRT, NSAID, ASHKENAZI, RACE) choose Byte for Field Size in the field properties pane. Byte allows entry of positive integers up to 255. For numeric variables requiring a longer field or that will hold numbers you will compute with select Integer as the Field Size. Make sure to Select 0 for Decimal Places, and delete the 0 from Default Value. Assign a default value for fields that will be skipped over assigning the value you want in place when the field is skipped. For example, when GRAVID=0 (meaning never pregnant) this implies for the fields that will be skipped: PARITY = 0 (no live births) AGE_FLB= 99 (not applicable no age at first live birth) BRSTFEED = 0 (No, never breastfed) Tip - The Validation Rule field can be used to avoid data entry errors from invalid responses. This is illustrated below for LMP_MON (Month of last menstrual period). It is usually paired with Validation Text which contains instructions for data entry if there is an error (Fig 5). The instruction (>=1 And <=12) Or =99 specify valid values for the month. If any other value is entered the message Enter a month between 1 and 12 or 99 if unknown will appear on screen. Fig 5: Field Properties panel for variable LMP_MON illustrating Validation Rule MS Access 2010 Example V2.Doc - 12 -

(3.3) For the date variables DOB and DOP, do the following: At the bottom of your screen, in the panel called Field Properties and in the tab GENERAL, choose the following settings: Format: Short date Input mask: 90/90/0000;0;_ Caption: Date of birth or Date of procedure Required: No Indexed: No IME Mode: No control IME Sentence Mode: None Note - The field properties pane for DOB demonstrates specification of a date/time variable. Here we ds using Short Date to enter dates in MM/DD/YYYY format. The Input Mask as shown in Fig 6 provides the format for the data entry so that there is no need to type the slashes when entering dates the slashes will be added automatically. Fig 6: Field Properties pane for a Date/Time variable (3.4) For the text variable ETHNICITY do the following: Enter a field size large enough to accommodate anticipated responses. Here we ve selected 20. (3.5) For all the variables except BCP, DOB, DOP, LMP_YR and ETHNICITY do the following: At the bottom of your screen, in the panel called Field Properties and in the tab GENERAL, choose the following settings: Field Size: Byte or Integer Decimal Places: 0 Default value: delete the value 0 that MS Access has provided by default MS Access 2010 Example V2.Doc - 13 -

2.7) When finished entering variables, click the Save button. Fig 7: Save the Table A popup window appears for you to enter the table name. Type tblgail in the box. (Fig 8). Fig 8: Save As Click OK MS Access 2010 Example V2.Doc - 14 -

f. Create the lookup tables that are needed to produce the drop down lists. In this step you are doing the first of several steps required in MS Access in order of have drop down menus. In this first step, you are creating the lookup tables that MS Access requires. From there, you will create the associated combo boxes. Recall - The 4 lookup tables that provide responses for the drop down menus will be named tblyesno, tblmenop, tblashken, and tblrace. Each table contains contain 2 fields a numeric variable that stores the codes, and a text variable that provides the descriptions of the codes. First, create the tables in design mode with the numeric variable containing the codes being the key variable. In this case Byte is adequate for the field size. The field size for the text variables varies depending on the responses. Table 1 shows the variables and the field sizes for the text variables. Combo Box tables: Table Name Name of Code Variable (*Primary key) Data Type Field Size Name of Description Variable Data Type Field Size 1 tblyesno codeyn Number Byte yesno Text 15 2 tblmenop codemenop Number Byte menop Text 15 3 tblashken codeashken Number Byte txtashken Text 20 4 tblrace coderace Number Byte textrace Text 35 Be sure to designate the code variable as key when defining the tables. The code will be used to link the code in the data to the description in the drop down box. Next, switch to datasheet view: Enter data in each table to show the code with corresponding description. Numeric Code Fig 9: tblyesno Text Description Fig 10: tblmenop Fig 11: tblashken Fig 12: tblrace MS Access 2010 Example V2.Doc - 15 -

g. Create the data entry form. Design Form for Data Entry At this point you have created a mechanism to store the data the table tblgail is ready to hold the data. Think of it as an empty spreadsheet that is ready for data entry. The next step is to produce a form that will enable accurate data entry in a format that mimics the data collection instrument. This is a short form that only requires a one page data entry screen. Instruments with several pages might require tabbed forms with a separate tab for each page. 1) To design your form: CREATE > FORMS > Form Wizard Fig 13: Select tblgail from the drop down list of Tables/Queries 2) The wizard then asks you select the fields for the form. You could select all available fields by clicking the double arrow (>>) to move all fields to the right hand pane, or individually select each variable and click the single arrow (>) to move it to the selected fields pane. In the figure below I ve selected all the fields except the ones with fixed choices for which I ll use combo boxes with the responses in the tables created in step 3.2. That is: select all except BCP, MENSTAT, BRSTFEED, HRT, NSAID, ASHKENAZI, HISPANIC and RACE. MS Access 2010 Example V2.Doc - 16 -

Fig 14: Choose variables for the form Click NEXT. 3) Select a Columnar layout for the form as shown in Fig 15 Fig 15: Select form layout Click NEXT. MS Access 2010 Example V2.Doc - 17 -

4) Name your form by typing frmgail in the title box and select Modify the form s design to work on mimicking the appearance of the data collection instrument. Fig 16:Finish the Wizard Click FINISH h. Modify the data entry form for readability and to mimic appearance of the paper form. 1) Position the curser at the top of the Form Footer bar and drag it down to make the form size bigger (to the 10 mark). 2) Position the curser at the right edge of the detail page and drag it out to 8.5 using ruler. 3) Place the curser at the top edge of the detail bar and pull it down to create space for a form header. 4) Select the Label tool from the left hand toolbar and draw a box in the Header space above the Detail bar. Click inside the box and type BREAST CANCER STUDY Next press Ctrl Enter to go to a new line and type GAIL RISK DATA At FORMAT > FONT: Select the box. Using the tool bar, select bold and centered. 5) Rearrange the variable boxes and labels in the detail section to be in the correct places on the form. a) Click on the text box for ethnicity and roll the mouse over it until a cross symbol appears, then click and drag it, with its accompanying label to the bottom of the form. b) Then, starting below and to the right of the LMP_YR text box, click and drag the mouse until a rectangle forms encompassing the text boxes and labels for LMP_MON, LMP_DAY and LMP_YR. Release the mouse. Those 3 variables are now selected. Again, roll over with the mouse until a hand appears and drag all 3 variables to a spot below NUM2NDDEG. c) Click outside of the boxes to release them. MS Access 2010 Example V2.Doc - 18 -

d) Select the text box for LMP_MON by clicking on it. e) Roll the mouse to the upper left corner of the text box until it changes to a cross symbol. f) Click and drag the text box (without the label) to a position further to the right of the label. g) Now select the label box for LMP_MON. Roll the mouse over the right horizontal handle until it makes a double headed arrow, and click and drag the mouse to the right to increase the width of the box. Type the label Q11. Date of Last Menstrual Period: in the box. h) Select the text box for LMP_DAY by clicking on it. Roll the mouse to the upper left corner of the text box until it changes to a cross symbol. Click and drag the text box (without the label) to a position to the right of the text box for LMP_MON. i) Repeat this procedure for the LMP_YR text box, so that it is to the right of LMP_DAY. j) Now, using the pointing finger, move the corresponding labels for LMP_DAY and LMP_YR until they are below the text boxes. k) Click inside the label for LMP_DAY and edit it to read DD. Click inside the label for LMP_YR and edit it to read YYYY. l) Use the label tool Aa to draw a new label box below the text box for LMP_MON and type MM inside it. m) Also place a new label below Q11 label box and type ENTER 99 OR 9999 IF UNKNOWN in it. n) Adjust the sizes of all the boxes to be appropriate to the width of the data that they will contain. Fig 17: Continue Form Design 4) Header label 5g) Modified label for LMP_MON 5h, 5i) Repositioned text boxes 5m) New instruction 5l) New label box for MM MS Access 2010 Example V2.Doc - 19 -

6) Next rearrange the variables and labels, to match the form, editing the labels and adjusting the widths. 7) Add labels with instructions such as ENTER 99 IF UNKNOWN in the appropriate spots. 8) The form should now look something like Fig 18. Fig 18: Modified Form Design MS Access 2010 Example V2.Doc - 20 -

i. Create the drop down menu combo boxes. To create a combo box for the variable BCP: In this step, you will create a combo box that makes use of the yes/no drop down menu stored in the table named tblyesno. You will then associate it with the variable BCP. a) Click on the combo box icon from Design -> Control -> combo box. b) Position your cursor in the detail area to the right of the ID variable. CLICK. This starts the combo box wizard. c) I want the combo box to get the values from another table or query is selected as the default. Fig 19: Combo Box Wizard Click NEXT. d) Next, select Table: tblyesno Fig 20: Combo Box Wizard Table Click NEXT MS Access 2010 Example V2.Doc - 21 -

e) You will see codeyn and yesno as the available fields. Click the double arrow (>>) to move them both to the Selected Fields list. Fig 21: Combo Box Wizard Fields Click Next f) Choose the field codeyn for ascending sort order g) Adjust the width of the text field (yesno) to be as wide as the longest response by double clicking the right border. Keep hide key column checked. Fig 22: Combo Box Wizard Column Width Click NEXT MS Access 2010 Example V2.Doc - 22 -

h) Click Store that value in this field: and select BCP from the drop down box. In doing this, you are telling MS Access to associate the information in tblyesno with the variable BCP Fig 23: Choose Variable to be associated with Combo Box Click NEXT. i) Type a label in the dialogue box What label would you like for your combo box? This label appear like a caption on the data entry form. Fig 24: Complete Combo Box Wizard Click Finish MS Access 2010 Example V2.Doc - 23 -

To finish up associating the combo box with the field BCP: j) Under DESIGN > TOOLS: click on Property Sheet Choose the tab labeled All At the entry Name type in the field name BCP (Fig 25) k) Before closing this box, scroll down until you see List rows. Note it doesn t quite show up in Fig 25 but you ll see it once you scroll down.. Change the value from 16 to 3. You only want 3 choices (no, yes, unknown) here. Fig 25: Name the Combo Box Click on the X at the upper right to close the Properties box. Similarly, create a combo box for each of MENSTAT, BRSTFEED, HRT, NSAID, ASHKENAZI, HISPANIC, and RACE Repeat steps a through k to create combo boxes for Q12 Q18 (please refer to the questionnaire), choosing the appropriate table for the responses (tblyesno for BRSTFEED, HRT, NSAID, HISPANIC, etc), naming each combo box to match the variable it represents, and editing the labels to match the form. MS Access 2010 Example V2.Doc - 24 -

j. Edit form for correct data entry order. MS Access allows you to rearrange the order of data entry prompts on the form. Since we added the combo boxes to the form after the other fields, the cursor will move to those late additions after the other fields. Our goal here is to reset the order to match the question order. To do this: DESIGN > TOOLS > Tab Order on the horizontal task bar Example - Select (highlight) the BCP row and move it to the second position under IDNUM. - Select the ETHNICITY row and move it to the last position. - Make sure the other fields appear in correct order. MS Access 2010 Example V2.Doc - 25 -

k. Additional formatting for appearance on the screen. i) Starting at the left bottom of the detail area, click and drag a narrow rectangle to select all the labels and variables on the left of the form. ii) At the horizontal tool bar: ARRANGE > SIZE AND ORDERING > ALIGN Now the alignment is neater and more uniform. iii) You can make similar changes to align variables and labels Top or Bottom if necessary. iv) Click the button at the top to the left of the horizontal ruler bar, to select the entire form a black square appears when the form is selected. Fig 26: Select Entire Form iv) v) Then click the Design -> property sheet button and change the setting for Record Selectors to No Fig 27: Remove Record Selectors from Form MS Access 2010 Example V2.Doc - 26 -

Other useful features to control data entry Your form is almost ready for data entry. It is helpful to have the form maximized at the start of data entry, to have the combo boxes you inserted on the form open automatically as the field is entered and to enable automatic skip patterns depending on the responses to questions. l. Create module with combo drop function. Name it module1. Return to the main database window and click Modules on the menu on the left. Click New to open a Microsoft Visual Basic window. Fig 28: Module 1 to create combodrop function Option Compare Database appears in the window. Type in the commands as shown in Fig 28 above. Save and close the module. Save it with name module1 MS Access 2010 Example V2.Doc - 27 -

m. Create the maximize form utility macro. In this step, you are writing a macro that tells MS Access to maximize the form at the start of data entry. It also tells MS Access to go to the ID variable of a new record. See Fig. 29. 1) Click Macros on the menu on top. 2) From the drop down list in the first row of the Action column, select MaximizeWindow 3) From the drop down list in the second row of the Action column select GotoRecord 4) From the drop down list in the third row of the Action column select GotoControl 5) In the Control Name box in the Action Arguments pane type IDNUM. 6) Click on the Save icon to save the macro. Give it the name Maximize Fig 29: Maximize Macro MS Access 2010 Example V2.Doc - 28 -

n. Create skip pattern utility macros. Recall that we want the following skip patterns. Response Prompting Skip Skip to destination The bypassed items are: The bypassed variables are: Q5: Gravid = 0 Q8: NUMBIOPS Q6 PARITY = 0 Q6: Parity = 0 Q8: NUMBIOPS Q7 AGE_FLB = 99 Q6: Parity = 0 Q14: HRT Q13 BRSTFEED = 99 Recall, also that we have already decided upon names for these macros: Macro to skip from Q5 to Q8 (Name: skptoq8) Macro to skip Q13 altogether (Name: skpq13) These are examples of macros that are executed, depending on a condition. In this example, one condition that prompts execution of a macro is Q5 gravid=0. The other is Q6: parity=0. To create macro skpq5toq8 which will skip the user to Q8 if they answer 0 to Q5 a) From the toolbar: CREATE > MACRO & CODE > macro. b) Select DESIGN > SHOW/HIDE > SHOW ALL ACTIONS c) Locate drop down menu at top of screen. From this drop down: Select IF d) In the box IF: type the following in f the condition for the skip pattern: [GRAVID]=0 Important Be sure that you have square brackets around the variable name. e) In the next drop down box: select GO TO CONTROL f) In the box labeled Control Name, type the destination of the skip pattern: NUMBIOPS g) Save the macro with the name skpq5toq8 In a similar fashion Create the macro skip skipq6toq8 which will skip the user to Q8 if they answer 0 to Q6. The condition to type into the box next to If here will be [PARITY]=0 MS Access 2010 Example V2.Doc - 29 -

To create macro skpq13frmq5 which will skip the user from Q12 to Q14 if they answer 0 to Q5 a) From the toolbar: CREATE > MACRO & CODE > macro. b) Select DESIGN > SHOW/HIDE > SHOW ALL ACTIONS c) Locate drop down menu at top of screen. From this drop down: Select IF d) In the box IF: type the following in f the condition for the skip pattern: [GRAVID]=0 e) In the next drop down box: again select IF f) In the box that appears next to IF: type the name of the variable that the skip pattern will begin at: MENSTAT g) In the next drop down box: select GO TO CONTROL h) In the box labeled Control Name, type the destination of the skip pattern: HRT i) Save the macro with the name skpq13frmq5 In a similar fashion Create the macro skip skipq13frmq6 which will skip the user from Q12 to Q14 if they answer 0 to Q6. The condition to type into the box next to the first If here will be [PARITY]=0 MS Access 2010 Example V2.Doc - 30 -

o. Apply the modules, combodrop function, and macros. Apply the maximize macro a) Return to the forms section of the database, select frmgail and click design to open it in design mode if it is not already open. b) Select the entire form by clicking on the button at the top to the left of the horizontal ruler bar. c) Click on the properties button d) Click the Event tab in the properties window e) Click in On Open and select the maximize macro from the drop down list If the combo function has not already been applied - Apply the combodrop() function that you created in module1 To do this for the variable BCP: a) Click on the BCP combo box The properties window should still be open and now displays the event properties for BCP b) Click in the On Got Focus box and type =Combodrop() (Fig 30) Fig 30: Apply combodrop() function Repeat steps a and b for each of the other combo boxes The other combo boxes are MENSTAT, BRSTFEED, HRT, NSAID, ASHKENAZI, HISPANIC and RACE MS Access 2010 Example V2.Doc - 31 -

Apply the macros to control skip patterns For the skip pattern executed by skpq5toq8 a) Click on the text box for GRAVID (Q5) b) In properties, click in the On Exit box and select the macro skpq5toq8 from the drop down list For the skip pattern executed by skpq6toq8 a) Click on the text box for PARITY b) Click in the On Exit box and select the macro skpq6toq8 from the drop down list For the skip pattern executed by skpq13frmq5 a) Click on the text box for MENSTAT b) Click in the On Exit box and select the macro skpq13frmq5 from the drop down list For the skip pattern executed by skpq13frmq6 a) Click on the text box for MENSTAT b) Click in the On Exit box and select the macro skpq13frmq6 from the drop down list Save the form! MS Access 2010 Example V2.Doc - 32 -

Now You Can Test the Form! Switch to form view Enter data to check that the form works as intended The data will be stored in tblgail One last note You can configure MS Access to open the form automatically MS Access has a feature that allows you to customize its launch, so that it opens to data entry automatically when access starts. 1) Click Tools on the horizontal task bar at the top. 2) Click Startup 3) From the drop down list under Display Form/Page:, select frmgail as shown in Fig 31 below. Fig 31: Automate Data Entry at Startup When data entry is complete When data entry is complete the form can be closed by clicking the x for the form in the upper right corner below the x for Microsoft Access. MS Access 2010 Example V2.Doc - 33 -