Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 12

IS 4420 - Access Lab 2

Objectives: A. Create data entry forms including forms on single table and main/sub forms B. Generate reports C. Use form to create user interface. D. Design more advanced forms E. In class exercise

A. Create Data Entry Forms


1. Create a orm or !e"artment tab#e. Clic on Forms button in t!e database "indo"# and t!en clic on $e% toolbar button. In t!e drop$ do"n box labeled %C!oose t!e table or &uery "!ere t!e ob'ect(s data comes from)# select !e"artment table from t!e list. *o as ACCE++ !elp us build a form using !e"artment table# please select Form &i'ar! in t!e list and t!en clic on O(.

+pecify t!e particular fields you "ant to include in t!e form. Assuming you "ant all t!e fields from !e"artment table# clic on t!e button "it! t%o ri)*t-"ointin) arro%s. *!en# please clic on $e+t button to continue.

C!oose a specific type of form layout for Co#,mnar and t!en clic on $e+t button to continue. C!oose a particular style for t!e form and t!en clic on $e+t button. -ame t!e form .e.g.# De"artment/ and clic on Finis* button. At t!is point# a form .e.g.# named !e"artment/ !as been created.

2. Create a orm -main an! s,b- orm. to !is"#ay an! s,""ort ,"!atin) in ormation abo,t em"#oyee an! t*eir !e"en!ents. *o create em"#oyee main orm# please repeat t!e steps in ,. Clic on Forms button in t!e database "indo" and t!en clic on $e% button on t!e toolbar. In t!e drop$do"n box labeled %C!oose t!e table or &uery "!ere t!e ob'ect(s data comes from)# select em"#oyee table from t!e list. *o as ACCE++ !elp us building a form using em"#oyee table# please select Form &i'ar! in t!e list and t!en clic on O(. Clic on t!e button "it! t%o ri)*t-"ointin) arro%*ea!s to select all t!e columns in t!e em"#oyee table into t!e form. *!en# clic on $e+t button to continue. C!oose a particular layout type for Co#,mnar and t!en clic on $e+t button to select form style. -ame t!e form .e.g.# Em"#oyee/ and t!en clic on Finis* button. At t!is point# a ne" form .e.g.# Em"#oyee/ !as been created. After creating Em"#oyee form# clic on Desi)n button in t!e database toolbar and select t!e form design mode.

/a+imi'e t!e form design "indo" and move t!e cursor to ,""er border of t!e orm ooter and !ra) it !o%n. By doing so# you can !ave more display space to include a dependent subform in t!e form .e.g.# Em"#oyee/. Clic on s,b orm button in t!e floating toolbox panel and your cursor "ill loo li e . .If you cannot see t!e toolbox# go to 0ie% menu and select 1oo#bo+ button and t!en 1oo#bo+ panel s!ould s!o" up/. -ext# go to t!e gray area and drag a rectan),#ar to create a subform in Em"#oyee main form. A s,b orm %i'ar! "ill t!en pop up automatically.

In s,b orm %i'ar! !ia#o) bo+# select 23se e+istin) tab#es an! 4,eries5 and clic on $e+t button. Assuming "e "ant to include all t!e columns in !e"en!ent table in em"#oyee main form# "e c!oose !e"en!ent table from t!e drop$do"n menu and clic on t!e button "it! t%o ri)*t"ointin) arro%*ea!s .to include all columns/. *!en# clic on $e+t button to continue. -ext# select 2De ine my o%n5 to define t!e specific fields in t!e main form to b lin ed to t!e subform. 2e "ill t!en use SS$ in em"#oyee main form to lin "it! ESS$ in !e"en!ent subform.

Clic on $e+t button and t!en name t!e subform .e.g.# De"en!entS,b orm/. Upon clic on Finis* button# you !ave created a form t!at displays t!e data of eac! employee# toget!er "it! !is or !er dependent.s/.

6. Create a orm t*at can !is"#ay in ormation o a !e"artment an! its #ocation-s.. Clic on Forms button in t!e database "indo" and t!en clic on $e% button in t!e toolbar. In t!e drop$do"n box labeled %C!oose t!e table or &uery "!ere t!e ob'ect(s data comes from)# select !e"artment table from t!e list. *o as ACCE++ !elp us building a form using !e"artment table# select Form &i'ar! in t!e list and t!en clic on O(. Clic on t!e button "it! t%o ri)*t-"ointin) arro%*ea!s to include in t!e form all t!e columns in !e"artment table and t!en clic on $e+t button to continue. +elect a particular layout type for Co#,mnar and t!e clic on $e+t button to define form style. -ame t!e form .e.g.# De"artmentLocation/ainForm/ and t!en clic on Finis* button to create a main form. After creating De"artmentLocation/ainForm# clic on Desi)n button in t!e database toolbar to activate t!e form design mode. 3

/a+imi'e t!e form design "indo" and move your cursor to t!e ,""er border of t!e orm ooter and !ra) it !o%n. By doing so# you can !ave more display space to include a department location subform in t!e form .e.g.# De"artmentLocationS,bForm/. Clic on s,b orm button in t!e floating toolbox panel and your cursor "ill loo li e . .If you cannot see t!e toolbox# go to 0ie% menu and select 1oo#bo+ button and t!en 1oo#bo+ panel s!ould s!o" up/. -ext# go to t!e gray area and drag a rectan),#ar to create a subform in De"artmentLocation/ainForm. A s,b orm %i'ar! "ill t!en pop up automatically. Assuming t!at "e "ant to include all t!e columns in De"t7Locations table in t!is subform# select !e"t7#ocations table from t!e drop$do"n menu and clic on t!e button "it! t%o ri)*t-"ointin) arro%*ea!s to include all t!e columns in dept4locations table. *!en# clic on $e+t button to continue. -ext# select 2De ine my o%n5 option to define t!e particular fields of t!e subform to be lin ed to t!e main form. 5lease use De"$o in De"artmentLocation/ainForm to lin to De"$o in De"t7#ocationsS,b orm. Clic on $e+t button and t!en name t!e subform .e.g.# De"tLocationsS,b orm/. Upon clic ing on Finis* button# you !ave created a form t!at displays data on departments and t!eir locations.

8. 9enerate a :e"ort
,. Design a report t!at lists all employee information# grouped by department number. Clic on t!e %:e"ort) ob'ect button in t!e database "indo"# and t!en clic on t!e %$e%) button on t!e toolbar. In t!e drop$do"n box labeled %C!oose t!e table or &uery "!ere t!e ob'ect(s data comes from)# select em"#oyee table from t!e list. *o as Access !elp us building a form using t!e %department) table# please select t!e %:e"ort &i'ar!) on t!e list and t!en clic on %O(). Assuming t!at "e "ant to include in t!e report all t!e columns except address in t!e %employee) table# please clic on t!e b,tton %it* t%o ri)*t-"ointin) arro%s to select all t!e columns and t!en use t!e b,tton %it* one #e t-"ointin) arro% to ,nse#ect t*e a!!ress co#,mn. *!en# clic on t!e %$e+t) button to continue. +elect t!e %De"$o) on t!e left$!and side menu and t!en clic t!e rig!t$arro" to include it in t!e group$level of t!e report. By doing so# you can generate a report t!at groups all employee information using department number. *!en# clic on %$e+t) button to continue.

In t!e next dialog box# clic on t!e %S,mmary O"tion) button# c!ec on t!e %av)) option and clic on %O(). +elect %A#i)n #e t 1) be t!e report layout and %Lan!sca"e) be t!e orientation. *!en# clic t!e %$e+t) button to continue. After selecting a particular style you li e for t!e report and naming t!e report .e.g.# EmployeeInfo/# clic on t!e %Finis*) button and Access "ill t!en automatically generate a report t!at groups all employee information by %Dep-o) and s!o"s eac! department(s average salary. 7ou can al"ays clic on t!e %Desi)n) button on t!e database toolbar to reformat a report. After you complete redesigning t!e report# you can go to t!e %0ie%) menu and c!oose %#ayo,t "revie%) to see t!e outcomes. .

0. Design a report t!at lists all department information. Clic on t!e %:e"ort) ob'ect button in t!e database "indo"# and t!en clic on t!e %$e%) button on t!e toolbar. In t!e drop$do"n box labeled %C*oose t*e tab#e or 4,ery %*ere t*e object;s !ata comes rom)# select %!e"artment) table from t!e list. *o as Access to !elp us building a form using t!e department table# please select t!e %:e"ort &i'ar!) in t!e list and t!en clic on %O(). Assuming "e "ant to include in t!e report all t!e columns in t!e %!e"artment) table# please clic on t!e b,tton %it* t%o ri)*t-"ointin) arro%s to select all t!e columns. *!en# clic on t!e %$e+t) button to continue. Assuming you don(t "ant to include grouping in t!e report# please simply clic on t!e %$e+t) button to continue. In t!e next dialog box# please select t!e %De"$o) column from t!e drop$do"n menu and t!en clic on t!e %Ascen!in)) button on t!e rig!t to sort %De"$o) by descending order. Clic %$e+t).

+elect %1ab,#ar) be t!e report layout and %<ortrait) be t!e orientation. *!en Clic on t!e %$e+t) button to continue. After selecting %cor"orate) be t!e report style and clic ing on t!e %$e+t) button advance to t!e final step# name t!e report .e.g.# De"artmentList/ and t!en clic on t!e %Finis*) button to create t!e report.

C. Create ,ser inter ace ,sin) Form


,. Clic on t!e %Form) ob'ect button in t!e database "indo"

0. Double clic %Create orm in Desi)n vie%)# you "ill see a ne" form

1. Clic t!e %Comman! 8,tton) in t!e %*oolbar)# drag and create a command button in t!e form area# and you "ill see t!e follo"ing screen9

3. +elect %:e"ort O"erations) .select %;orm <perations) "!en it(s a form/ in t!e %Categories) and %<revie% :e"ort) .select %<pen ;orm) "!en it(s a form/ in t!e %Actions)# clic %$e+t). 6. +elect t!e Em"#oyee re"ort and clic %$e+t) 8. Clic %1e+t) and c!ange %5revie" =eport) to %Em"#oyee :e"ort)# clic %$e+t) :. C!ange t!e command name to %cm!De"artment:e"ort)# clic Finis*. >. ;ollo" similar process to create t!ree more buttons called %Department =eport)# %Department ;orm)# and %Employee ;orm)# clic t!e %+ave) button and save t!e form as %?ain)# and you "ill see t!e "indo" as t!e follo"ing9

>

@. Go to t!e Form 0ie%# and you can clic t!e buttons to open t!e reports and forms you "ant.

D. Create more a!vance! orms


In t!is section "e are going to create a more advanced form t!at includes ,/ more complex toolbar ob'ects suc! as combo box# list box# etc. and 0/ command button "it! ABA code. *!is form is for entering ne" dependent information. ,. Clic on t!e %Form) ob'ect button in t!e database "indo" 0. Double clic %Create orm in Desi)n vie%) 1. +ave t!is form as orm$e%De"en!ent 3. *!ere are five fields in t!e Dependent table# t!erefore "e s!ould !ave five corresponding toolbar ob'ects. But since "e no" t!e sex of t!e dependent given t!e relations!ip bet"een t!e employee and t!e dependent# "e only need four toolbar ob'ects instead 6. Create a combo box for E++a. clic Combo 8o+ on t!e *oolbar b. clic $e+t c. select 3SE:==7E/<LO>EE tab#e# and clic $e+t @

d. add SS$? F$A/E? /I$I1? an! L$A/E from t!e available fields to t!e selected fields# and clic $e+t e. Unc!ec @i!e Aey co#,mn# and clic $e+t f. ?a e sure SS$ is selected# and clic $e+t g. Enter Em"#oyee SS$ under 2!at label "ould you li e for your combo box# and clic Finis* !. Double clic t!e combo box# c!ange t!e -ame to cboESS$ i. +"itc! from Design Aie" to Form 0ie%# you "ill see !o" t!e combo box "or s '. +"itc! bac to Desi)n 0ie% 8. Create a text box for Dependent4-ame a. clic 1e+t 8o+ on t!e *oolbar# and create a text box on t!e form b. c!ange t!e Caption of t!e label to De"en!ent $ame c. c!ange t!e -ame of t!e text box to t+tD$ame :. Create a text box for +ex a. clic 1e+t 8o+ on t!e *oolbar# and create a text box on t!e form b. c!ange t!e Caption of t!e label to De"en!ent 8irt* Date c. c!ange t!e -ame of t!e text box to t+t8Date >. Create a list box for =elations!ip a. clic List 8o+ on t!e *oolbar# and create a list box on t!e form b. select I %i## ty"e in t*e va#,es t*at I %ant# and clic $e+t c. under Col,# enter four ro"s of data9 @,sban!? &i e? Son? an! Da,)*ter# and clic $e+t d. enter :e#ations*i" under 2!at label "ould you li e for your list box e. c!ange t!e -ame of t!e list box to #st:e#ations*i" .t!e first lettler is a lo"er case B/ @. Add a command button to save t!e entered data a. clic Comman! 8,tton on t!e *oolbar# create a command button# and clic Cance# b. c!ange t!e Caption of t!e command button to Save c. c!ange t!e -ame of t!e command button to cm!Save d. in t!e property "indo" for cmd+ave as s!o"n belo"# select Event <roce!,re after <n Clic # and clic t!e B button

,C

e. type in t!e ABA code belo" bet"een t!e t"o solid double lines. DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD 5rivate +ub cmd+ave4Clic ./ Dim strE++- As +tring Dim strD-ame As +tring Dim str+ex As +tring Dim str=elations!ip As +tring Dim strBDate As +tring Dim str+EB As +tring strE++- D cboEmployee.Aalue strD-ame D txtD-ame.Aalue str=elations!ip D lst=elations!ip.Aalue strBDate D txtBDate.Aalue If .str=elations!ip D F2ifeF <r str=elations!ip D FDaug!terF/ *!en str+ex D F;F Else Use your user ID. ;or example# if str+ex D F?F you(re user># type U+E=> End If str+EB D FI-+E=* I-*< U+E=004DE5E-DE-* values .GF H 4 strE++- H FG#GF H 4 strD-ame H FG#GF H 4 str+ex H FG#GF H 4 strBDate H FG#GF H 4 Double &uote# single &uote# comma# single &uote# double &uote str=elations!ip H FG/F DoCmd.=un+EB .str+EB/ End +ub

,C. Ad'ust t!e siIe# position# and color of t!e ob'ects on t!e form ,,. <pen t!e form# enter data as s!o"n belo" and clic Save

,,

,0. Clic >es ,1. <pen t!e De"en!ent table# you "ill see t!e ne" record "e 'ust added.

E. E+ercise:
5lease do t!e exercise in class if time permits. 7ou don(t need to submit t!e exercise. ,. Create a form t!at supports data input or update in 5ro'ect table. 0. Create a form t!at displays information about eac! employee and !is or !er department name and manager(s social security number. 1. Create a report t!at lists all t!e dependent information# grouped by E++-# and add a button in t!e ?ain ;orm to vie" it. 3. Add buttons in t!e ?ain ;orm for t!e forms and reports created in t!is exercise.

,0

You might also like