Professional Documents
Culture Documents
MS Access 2010 Example v2 PDF
MS Access 2010 Example v2 PDF
-1-
-2-
-3-
-4-
Breast Cancer Code Sheet Data Collection Form Annotated with Variable Names
-5-
Variable Name
IDNUM
BCP
Q1
Q2
Q3
Q4
DOB
DOP
AGE_ATYP
MENARCHE
Q5
GRAVID
Q6
PARITY
Q7
AGE_FLB
Q8
NUMBIOPS
Q9
NUM1STDEG
Q10
NUM2NDDEG
Q11
Q12
LMP_MON
LMP_DAY
LMP_YR
MENSTAT
Q13
BRSTFEED
Q14
HRT
Q15
NSAID
Description
Unique Study Identifier
Numeric, 1-digit
1 - Premenopausal
2 - Perimenopausal
3 - Postmenopausal
9 - UNKNOWN
Numeric, 1-digit
0 - No
1 - Yes
9 - UNKNOWN
Numeric, 1-digit
0 - No
1 - Yes
9 - UNKNOWN
Numeric, 1-digit
0 - No
1 - Yes
9 - UNKNOWN
Menopausal Status
Date of Birth
Date of Procedure
Age at diagnosis of atypia
Age at Menarche
Number of times pregnant
Number of live births
Age at first live birth
History of Breastfeeding
History of Hormone
Replacement Therapy
-6-
Variable Name
ASHKENAZI
Q17
HISPANIC
Q18
RACE
Q19
ETHNICITY
Description
Ethnic Ancestry on list
Hispanic or Latina
Racial Background
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.
-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
Q12
Variable Name
MENSTAT
Q13
Q14
Q15
Q17
Q16
BRSTFEED
HRT
NSAID
HISPANIC
ASHKENAZI
Q18
RACE
Table in Access
Tblmenop
0 - No
1 - Ashkenazi Jewish
2 - Dutch
3 - Icelandic
4 - French Canadian
9 - UNKNOWN
1 - White
2 - Black/African Amer
3 - Asian
4 - Pacific Islander
5 - Native Amer.
6 - Multiracial
7 - Other
9 - UNKNOWN
Tblashken
Tblyesno
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
Q5: Gravid = 0
Skip to
destination
Q8: NUMBIOPS
Q6: Parity = 0
Q6: Parity = 0
Q8: NUMBIOPS
Q14: HRT
The bypassed
items are:
Q6
Q7
Q7
Q13
-8-
__d. Using a through c above, make a list of the lookup tables, macros and modules that
are desired.
5 Tables are needed:
(Name: tblGail)
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.
2.
3.
4.
(Name: maximize)
(Name: skpQ5toQ8)
(Name: skpQ6toQ8)
(Name: skpQ13frmQ5)
-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.
Note - At Required change No to Yes use required only for ABSOLUTELY required data
- 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
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
- 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
- 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:
Input mask:
Caption:
Required:
Indexed:
IME Mode:
IME Sentence Mode:
Short date
90/90/0000;0;_
Date of birth
or
Date of procedure
No
No
No control
None
Note - The field properties pane for DOB demonstrates specification of a date/time
variable. Here weds 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 weve 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
- 13 -
A popup window appears for you to enter the table name. Type tblGail in the box. (Fig 8).
Fig 8: Save As
Click OK
- 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:
1
2
3
Table Name
tblyesno
tblmenop
tblASHKEN
tblrace
Name of
Code Variable
(*Primary key)
codeyn
codemenop
codeashken
coderace
Data
Type
Number
Number
Field Size
Byte
Byte
Number
Byte
Number
Byte
Name of
Description
Variable
yesno
Field Size
15
menop
Data
Type
Text
Text
txtashken
Text
20
textrace
Text
35
15
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
Text Description
Fig 9: tblyesno
- 15 -
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 Ive selected all the fields except the ones with fixed choices for which Ill
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.
- 16 -
Click NEXT.
3) Select a Columnar layout for the form as shown in Fig 15
Fig 15: Select form layout
Click NEXT.
- 17 -
4) Name your form by typing frmGail in the title box and select Modify the forms 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.
- 18 -
4) Header label
5m) New
instruction
- 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
- 20 -
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
- 21 -
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
- 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
- 23 -
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.
- 24 -
- 25 -
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
- 26 -
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
- 27 -
- 28 -
The bypassed
variables are:
PARITY = 0
AGE_FLB = 99
BRSTFEED = 99
Recall, also that we have already decided upon names for these macros:
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
- 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
- 30 -
- 31 -
- 32 -
- 33 -