Tải bản đầy đủ (.pdf) (639 trang)

Access VBA programming (2004)

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.28 MB, 639 trang )

AccessVBAProgramming
ISBN:0072231971
byCharlesE.BrownandRon
Petrusha
McGraw-Hill/Osborne©2004(441pages)
Fromthebasicstoadvancedtechniques,this
comprehensivereferencedemonstrateshowto
connectAccessandVBAthroughADO,howto
extract,manipulate,andretrievedatausing
SQLqueries,benefitfromexpertadviceon
errorhandling,andmuchmore.
TableofContents
AccessVBAProgramming
Introduction
PartI-UnderstandingtheMSAccessEnvironment

Chapter1
Chapter2
Chapter3
Chapter4

- IntroductiontoVBAforApplications
- DesigninganAccessApplication
- AccessDevelopmentWithoutVBA
- CustomizingtheAccessEnvironment

PartII-UnderstandingtheVisualBasicfor
ApplicationsEnvironment

Chapter5 - IntroducingtheVBAProgramming
Environment


Chapter6 - ProgrammingFundamentalsUsingVBA
Chapter7 - UnderstandingtheVisualBasicEditor
Chapter8 - VBALanguageComponents
Chapter9 - SubProcedures
Chapter10 - DebuggingVBACode


Chapter11 - FunctionProcedures
PartIII-InteractingwithVBA

Chapter12 - Forms
Chapter13 - Reports
Chapter14 - MenusandToolbars
Chapter15 - ChangingtheAccessEnvironment
PartIV-AdvancedAccessProgrammingTechniques

Chapter16 - DatabaseSecurity
Chapter17 - AccessandtheMicrosoftOffice
Environment
Chapter18 - AccessandtheWeb
Chapter19 - Upgrading
PartV-ApplicationDevelopment

Chapter20 - MultiuserApplications
Chapter21 - BeyondMicrosoftAccess
Appendix - TheDoCmdObject
Index
ListofFigures
ListofTables



BackCover
ExpandtherangeofyourAccessproficiencywithVBA
programming,usingthisguidedesignedspecificallyfor
Accesspowerusers.LearnVBAfundamentals,then
discoverhowtoconnectAccessandVBAthrough
ActiveXDataObjects(ADO),andhowtoextract,
manipulate,andretrievedatausingSQLqueries.
Benefitfromexpertadviceonerrorhandling,getthe
mostoutofforms,reports,andtables,andsavetime
withVBAcodinganddebuggingtips.Fromthebasics
toadvancedtechniques,thiscomprehensivetreatment
providesyouwiththeinformationyouneedtoproduce
theexactresultsyoudesire.
CallupformsandreportsusingVBA
BuilddynamicDataAccessPages
Programandassignrecorddatasourcestoforms
andreports
LearnthefundamentalsofSQLandhowtouseit
inVBA
UnderstandtheADOobjectmodelandits
components
Usemodules,declarevariables,buildloopingand
decisionstructures,useproceduresandfunctions,
andbuildarrays
Generaterecordsetsbasedondynamiccriteria
UseOfficemenusandtoolbarstoinvokeyour


code

Developapplicationsthatmultipleuserscanrun
atthesametime
AbouttheAuthors
CharlesE.BrownhastaughtVBAprogrammingto
manybeginnerprogrammers,andhasproducedVBA
codeforSwissBankCorporation,theUSgovernment,
NASA,andPriceWaterhouseAccounting.
RonPetrushaisacomputerbookauthorandeditor
withover25yearsofexperienceindeveloping
computerapplications.


AccessVBAProgramming
CharlesE.Brown
RonPetrusha
McGraw-Hill/Osborne2100PowellStreet,10thFloorEmeryville,
California94608U.S.A.
Toarrangebulkpurchasediscountsforsalespromotions,premiums,or
fund-raisers,pleasecontactMcGraw-Hill/Osborneattheaboveaddress.
ForinformationontranslationsorbookdistributorsoutsidetheU.S.A.,
pleaseseetheInternationalContactInformationpageimmediately
followingtheindexofthisbook.
AccessVBAProgramming
Copyright©2004byTheMcGraw-HillCompanies.Allrightsreserved.
PrintedintheUnitedStatesofAmerica.Exceptaspermittedunderthe
CopyrightActof1976,nopartofthispublicationmaybereproducedor
distributedinanyformorbyanymeans,orstoredinadatabaseor
retrievalsystem,withoutthepriorwrittenpermissionofpublisher,withthe
exceptionthattheprogramlistingsmaybeentered,stored,andexecuted
inacomputersystem,buttheymaynotbereproducedforpublication.

1234567890FGRFGR01987654
ISBN0-07-223197-1
Publisher
BrandonA.Nordin
VicePresident&AssociatePublisher
ScottRogers
EditorialDirector
WendyRinaldi
ProjectEditor
CarolynWelch


AcquisitionsCoordinator
AthenaHonore
TechnicalEditor
DavidSchulz
CopyEditor
JudithBrown
Proofreader
MarianSelig
Indexer
ClaireSplan
Composition
LucieEricksen
JohnPatrus
KellyStanton-Scott
Illustrators
KathleenEdwards
MelindaLytle
GregScott

SeriesDesign
RobertaSteele
CoverDesign
TomSlick
ThisbookwascomposedwithCorelVENTURA™Publisher.
InformationhasbeenobtainedbyMcGraw-Hill/Osbornefromsources
believedtobereliable.However,becauseofthepossibilityofhumanor
mechanicalerrorbyoursources,McGraw-Hill/Osborne,orothers,
McGraw-Hill/Osbornedoesnotguaranteetheaccuracy,adequacy,or
completenessofanyinformationandisnotresponsibleforanyerrorsor
omissionsortheresultsobtainedfromtheuseofsuchinformation.


AbouttheAuthors
CharlesE.Brownisoneofthemostnotedauthors,teachers,and
consultantsinthecomputerindustrytoday.Hisfirsttwobooks,Beginner
DreamweaverMXandFireworksMX:ZerotoHero,havereceivedcritical
acclaimandareconsistentbestsellers.Thisyear,Charleswillbe
releasingbooksonVBAforMicrosoftAccess,andthenewMicrosoft
FrontPageenvironment.HeisalsoaFireworksMXcontributorfortheMX
Developer’sJournal.Inadditiontohisbusywritingschedule,heconducts
frequentseminarsforFutureMediaConcepts,speakingaboutthe
Macromediadevelopmentenvironment.In2004,hewillalsobeinvolved
indevelopinge-learningcoursesusingMacromedia’sRoboDemo
developmentenvironment.
WhenCharlesisnotwritingandteaching,heisaconsultantformany
high-profilewebsites.Thisyear,heisplacingalotofhisweb
developmenteffortswiththeFlashMX2004Professionalenvironment.
Hefeelsstronglythatthisisthefutureofwebdevelopment.
Charlesisalsoanotedclassicalorganist,pianist,andguitaristwho

studiedwithsuchnotablesasVladimirHorowitz,VirgilFox,andIgor
Stravinsky.ItwasbecauseofhisassociationwithStravinskythathegot
tomeet,anddevelopafriendshipwith,famed20th-centuryartistPablo
Picasso.
RonPetrushahasover25yearsofexperienceinthecomputerindustry
andistheauthoroftencomputerbooksandnumerousprintandonline
articles.HeistheprincipalofHowlingWolfConsultingServices,a
companythatprovideseditorialservicestothepublishingindustryand
alsooffersapplicationandwebdevelopmentservicesusingMicrosoft
technologies.Hecanbereachedat


Introduction


Overview
BeforetheintroductionofMicrosoftAccess,databasemanagement
systemsweresynonymouswithprogramming.Withoutprogramming,you
wereunabletotapintothefullpowerofthesoftware.Indeed,some
databasemanagementsystems,likeNantucketCorporation’sClipper,
consistedonlyofadevelopmentenvironmentandacompiler.The
databasedeveloperwasresponsiblefordesigningthedatabasesand
thenwritingallofthecodethatconstitutedhisorherapplication.
TheintroductionofMicrosoftAccessin1991changedallthat.Access
wasdistinguishedbyitsgraphicalapproachtodatabasemanagement,
whichalloweduserstotakeadvantageofsomepowerfulfeaturesofthe
DBMSwithoutneedingtodoanyprogramming.Byusingwizardsand
graphicaldesigners,Accessalloweduserstodesigndatabases,create
formsanduserinterfaces,writequeries,andgeneratereports.Itwasthis
powerandflexibilitycombinedwithitseaseofusethatquicklymade

Accesstheleadingdesktopdatabasemanagementsystem.
AlthoughprogrammingisnotrequiredtouseAccess,nevertheless,
Accesshasattractedahugeprogrammingaudience.Infact,more
programmersareworkingwithAccessthanwithanyotherdatabase
managementsystem.Therearetwomajorreasonsforthisapparent
contradiction:
Byprovidingsuchaneffectiverapidapplicationdevelopment
environmentfordatabaseapplications,Accesspromptsusersto
wanttolearnmoreaboutusingthesoftwaremorepowerfully,
effectively,andefficiently.Infact,manyprofessionalAccess
programmersbeganasAccessuserswhodevelopedapassion
fortheproductandexperiencedafrustrationoverthethingsthey
wantedtodobutdidn’tknowhowtodo.
Despiteitseaseofuse,usersatsomepointrunintothe
limitationsoftheAccessuserinterfaceandmustturnto
programming.AlthoughyoucandoagreatdealasanAccess


user,somethingscanonlybedoneprogrammatically.
Ifyou’vepickedupthisbook,you’renodoubtanAccessuserwhohas
hadbothoftheseexperiences.YouenjoyusingAccess,enjoythepower
thatitplacesatyourdisposal,andwanttolearnmoreaboutusingit
effectively.Atthesametime,youfindthatyou’rerunningintosomeofthe
limitationsoftheAccessinterfaceandsuspectthatifyou’retocontinueto
deepenyourskillsinusingAccess,youneedtoturntoprogramming.
Andperhapsyou’reevenbeginningtofindyourselfresponsiblefor
developingandmaintainingAccessapplications,possiblyinasmall
businesssetting,wheremostusershaveverylittleexperiencewiththe
Accessinterface.Inthatcase,thisbookisforyou.
AccessVBAProgrammingtakestheAccesspowerusertothenextlevel,

fromusingAccesstoprogrammingwithAccess,bybuildingonmuchof
whatyoualreadyknow.PartI,“UnderstandingtheAccessEnvironment,”
introducessomeofthebasicconceptsofprogramdesignand
architecture(likerequirementsanalysisandnamingconventions)atthe
sametimethatitreviewswhatyoucandoinAccesswithout
programming.Itincludesarefreshercourseonthemajorcomponentsof
anAccessapplication(includingmacros,modules,andevents),aswell
asadiscussionofsomeoftheinterfaceelementsyoucaneventuallyuse
toallowyourselfandotherusersaccesstothecodeyou’lleventually
write.ThisincludesusingtheSwitchboardManagerasthemenusystem
ofanAccessapplicationandcustomizingAccessmenusandtoolbarsso
thattheusercanexecuteroutinesbyclickingatoolbarbuttonor
selectingamenuitem.
PartII,“UnderstandingtheVisualBasicforApplicationsEnvironment,”
introducesyoutoVisualBasicforApplications(VBA),theprogramming
languageusedbyMicrosoftAccess(aswellasbytheotherOffice
applicationsandbyVisualBasic).Hereyou’lllearnaboutbasic
programmingconcepts,suchasvariables,arrays,objects,program
structures(loopingstructures,decision-makingstructures),functions,and
procedures.VBA,however,offersnotonlyaprogramminglanguage,but
acompleteintegrateddevelopmentenvironment(IDE)thatallowsyouto
run,test,anddebugyourcode.Thispartofthebookintroducesyouto
theVBAEditor,VBA’sIDE.Finally,VBAitselfhasnolanguageelements


thatsupportdataaccess.Instead,dataaccessishandledbyaseparate
library,ActiveXDataObjects(ADO),whichcanbecalledfromVBAcode.
PartIIintroducesyoutothebasicsofADOaswell.
Withthebasicsinplace,PartIIIofthebook,“InteractingwithVBA,”
beginstoshowyouhowyoucanputVBAtocreativeuseindeveloping

Accessapplications.ItcoversusingVBAwithformsandreports,creating
menusandtoolbarsprogrammatically,andcustomizingtheAccess
environmentbothfromtheOptionsdialogandprogrammatically.Inthis
partofthebook,youlearnnotonlyhowtouseVBAtogetAccessobjects
(likeformsandreports)torun,butalsotoconfiguretheAccessuser
interfacesothattheusercanrunyourapplication.
PartIV,“AdvancedAccessProgrammingTechniques,”introducessome
ofthemorespecializedareasofAccessdevelopment.You’lllearnabout
securityinAccess,anincreasinglyimportanttopicasAccessbecomes
morewidelyusedinnetworkedandmultiuserenvironments.You’llalso
learnhowtouseAccesstocreateDataAccessPagesforthewebandto
importdatafromotherOfficeapplications,likeExcelandWord.Chapter
19coversupgradingtoamoreenterprise-levelDBMSlikeMicrosoftSQL
ServerwhilecontinuingtouseAccessasafront-endthrougha
technologycalledAccessDataProjects(ADP).
PartV,“ApplicationDevelopment,”consistsoftwochapters,oneon
multiuserprogrammingandoneonprogrammingoutsideoftheAccess
environmentwiththeskillsyou’vedevelopedwhileprogrammingwith
Access.AsAccessevolvesfromasingle-user,desktopDBMStoa
networkedDBMS,thedemandsplacedonprogrammerstowriterobust,
efficientcodeincreases.Thechapteronmultiuserprogrammingcovers
someofthetechniquesyoucanusetomakesureyourapplication
performsasexpectedwhenmultipleusersareaccessingdata.Thefinal
chapter,“BeyondMicrosoftAccess,”demonstratesthattheskillsyou
havelearnedinthecourseofthebookareapplicablenotonlytoAccess,
butalsototheotherOfficeapplications,totheretaileditionofVisual
Basic,andeventoVBScriptandActiveServerPages.


WhoShouldReadThisBook?

AccessVBAProgrammingiswrittenfortheAccesspoweruserwhois
familiarwiththebasicsofcreatingdatabaseapplicationsusingthe
Accessinterface.ItassumesthatyouknowyourwayabouttheAccess
interfaceandarefamiliarwithcreatingtables,queries,andreportsusing
eitherwizardsorDesignView,andthatpossiblyyou’vecreatedforms
andrunAccessmacrosaswell.
Italsoassumesthatyou’rereadyandeagertotakethenextstep—either
thatyou’reexperiencingthelimitationsoftheAccessinterfaceandwant
tolearnmore,orthatyoufindyourselfinthepositionwhereyouneedto
knowmoreinordertocreateprofessionalapplicationsforotherusers.
AlthoughwehavewrittenthisbookusingAccess2003inallcases,we
havealsotesteditusingpreviousversionsofAccess.We’vealsotriedto
beassensitiveaspossibletodifferencesinAccessversions.Becauseof
this,thebookshouldserveasausefulintroductiontoAccess
programmingaslongasyou’reusingAccess97oralaterversion.


PartI:UnderstandingtheMSAccess
Environment


ChapterList
Chapter1:IntroductiontoVBAforApplications
Chapter2:DesigninganAccessApplication
Chapter3:AccessDevelopmentWithoutVBA
Chapter4:CustomizingtheAccessEnvironment


Chapter1:IntroductiontoVBAforApplications



Overview
In1992agoodfriendofminesaidtomethatthisnewdatabasepackage,
MicrosoftAccessversion1.0,isnevergoingtolast.Hefeltthatitwasnot
astrongenoughcontenderconsideringthecompetitionthatwasthen
available.
Hereweare,12yearslater,andevidencestronglyshowsthatmyfriend
wasquitewrong.NotonlyhasAccesslasted,butitisnowservingasthe
backboneformanylargewebsites.Ithassuccessfullycombineda
powerfuldatabaseenginewithaninterfacethatisfriendlyforeventhe
first-timeuser.Inmanyrespects,itnowrivalsMicrosoft’senterpriseSQL
Serverdatabaseenvironment.
WithMicrosoftAccess,youcanaccomplishalotwithoutany
programmingskillswhatsoever.However,withaknowledgeofVisual
BasicforApplications(VBA),youcandoatremendousamountof
customization,aswellasaddressalargenumberofscenarios.
Inthischapter,wearegoingtotakeabriefexcursionintothehistoryof
Access.WearethengoingtoexaminetheAccessenvironmentby
lookingathowtocreatethevariousobjectsthatmakeupadatabase.We
aregoingtotakeourfirstbrieflookattheVisualBasicEditor(VBE).
SincewearelookingatthehistoryofAccessinthischapter,wewill
concludebygazing,briefly,intoacrystalballandtakingaguessasto
whereMicrosoftmaybegoinginthefuture.


HistoryofMicrosoftAccess
MicrosoftAccesscameintobeingin1992withversion1.0andcoincided
withtheintroductionofMicrosoftWindows.Thisintroducednewsoftware
concepts(atleasttotheconsumermarket)suchasdraganddrop,form
andreportwritingcapabilities,andwizardstohelpthebeginnergetajob

done.Italsointroducedawayfordifferentdatabasepackagestotalkto
eachother.ThisnewtechnologywascalledODBC,orObjectDatabase
Connectivity.
Thefollowingyear,MicrosoftbuiltonthesefeatureswithAccess1.1.This
isalsotheyeartheypurchasedtheircompetition,FoxPro.SinceAccess
wasactuallypartoftheMicrosoftOfficeenvironment,theyintroducedthe
abilityfortheseOfficeprogramstocommunicatewitheachother.Asan
example,usersnowhadeasymail-mergecapabilitieswithMicrosoft
Word.Theprogramalsonowhadtheabilitytohandlemoredata.
In1994,Access2.0cameoutwithevenmorewizards,better
developmenttools,andsignificantimprovementstotheJetdatabase
enginethatmaderunningqueriesconsiderablyfaster.
WiththeintroductionofWindows95cametheintroductionofOffice95.
Inadditiontotheimprovedformandreportwritingcapabilities,VBAwas
formallymadethedevelopmentlanguagebehindalltheOfficeprograms.
In1997,theWebwasstartingtogrowandAccess97camewithtools
thathelpeditintegratewithwebapplications.Itwasabletospeakwith
HTMLandpublishdatatotheWeb.VBAalsotookastepcloserto
becomingmoreOOP(object-orientedprogramming)friendly,withthe
introductionofmodulestoholdtheVBAprocedures.Anumberofother
developmenttoolswerealsointroduced.
Access2000madeasignificantimprovementinprogrammingwiththe
introductionofActiveXDataObjects(ADO).Wewillbespendinga
significantpartofthisbookdiscussingthatverytopic.Thisversionalso
introducedincreasedcapabilitiesforworkingwiththeSQLServer
databaseengine.Access2002improvedonthiscapabilitybytightening
somethingcalledreferentialintegrity.Thismeansthatifdataiseditedin


onetable,thoseeditscascadetorelateddatainanothertable.Also,XML

capabilitieswereintroduced.
Finallythepresentversion,Access2003,hasexpandedtheXML
capabilitiesandaddedsomeuniqueprogramminganddebuggingtools.


DevelopinginAccess
Asstatedintheintroduction,Accesshassuccessfullycombineda
powerfuldatabasedevelopmentenvironmentwitharelativelyeasy-touseinterface.Ithasanumberofwizardsthatwillwalkyouthrougha
varietyofactionssuchasbuildingatable,aform,areport,oraquery.
Inthissection,wetakeabrieflookatthedevelopmentenvironment.
However,beforewebegin,wemustdistinguishbetweentwoterms:
databaseanddatabaseproject(note,thetermsdatabaseprojectand
databaseapplicationmeanthesamethingandwillbeused
interchangeablythroughoutthisbook).
Initssimplestform,adatabaseisacollectionofrelateddataheldina
structuredenvironment.Thedataisusuallyrelatedinordertomanipulate
ittoaccomplishatask.Mostdatabasesarerelationalandhavetoolsto
easilyrelatedata.Adatabaseapplicationisprogrammingtohelpthe
databasemanipulateanddeliverinformation.ThisiswhereVBAcomes
intoplay.

TheDatabaseWindow
WhenyoufirstopenAccess,youarepresentedwiththewindowshown
inFigure1-1.


Figure1-1:TheDatabasewindow
Thecomponentsofadatabaseenvironmentarecalleditsobjects.The



Databasewindowplacesthoseobjectsintocategories:Tables,Queries,
Forms,Reports,Pages,Macros,andModules.Sincethisisnota
beginningVBAbook,Iassumethatyouareexperiencedinusingmanyof
thefeaturesinthiswindow,butwe’lltakeabrieflookatthemechanicsof
usingit.
Youselectthecategoryyouwantusingthecolumnontheleft.Oncein
thatcategory,youshouldseethelistofavailableobjectsofthattype—for
instance,thetablesassociatedwithyourdatabase.Eachcategoryalso
presentsoptionsforcreatinganobject.Manycanbecreatedeither
manuallyorwiththeuseofawizard.Asanexample,ifyoudouble-click
onCreateTablebyUsingWizard,youarepresentedwiththescreen
showninFigure1-2.


Figure1-2:TheTableWizard
Hereyouselectthefieldsyouwantbyexamininganumberofprebuilt
tablesforvarioustypesofjobs.Youcanrenamethefieldstosuityour
purposes.Onceyouhaveselectedthefieldsyouwant,theNextbutton
takesyoutothenextstepnecessarytocompletethetable.Mostwizards
workthisway.
ReturningtotheDatabasewindow,youcanalsochoosetobuildthe
sametablebyhandbyselectingtheCreateTableinDesignViewoption.
YouarepresentedwithagridasshowninFigure1-3.



Figure1-3:TableinDesignView
Hereyoucannamethefield,selectadatatype,andprovidesomebrief
commentsaboutthefield.IntheFieldPropertiesareainthebottom
portionofthewindow,youcanassigndefaultvalues,datarules,and

formatting,forexample.
Whilethemechanicsmaybeslightlydifferent,formsandreportshave
similarfeatures.YoucanbuildthemeitherinDesignVieworbyusingthe
suppliedwizard.
Incaseyouhaveneverhadanoccasiontouseit,aDataAccessPage,
whichwasfirstintroducedinAccess2000,allowsyoutodisplay
informationinaformorreportontheWeb.Itconvertstheformorreport
toHTMLcodewhilebindingittothedataitisassociatedwith.
Thenicepartaboutthisfeatureisthat,eventhoughtheformorreportis
beingdisplayedinawebpage,youhaveallthesametoolsavailableasif
youwereusingitwithinthedatabaseenvironment.Youcanadd,delete,
ormodifydataaswellasscrollthroughitusingthebuttonsoftheformor
report.

Macros
Macrosaresimplecodethatreplicatesasequenceofstepswithin
Access.UnlikefullVBAprogramming,macroscannotmakedecisionsor
loopthroughablockofcodeacertainnumberoftimes.Theydonotuse
variables,norcanyoucustomizetheiroperationsthroughtheuseof
procedures.Theysimplymimicasequenceofoperationsthatyoucould
performyourselfmanually.


WhenyouselecttheMacroscategoryintheDatabasewindow,youwill
noticethattherearenowizards.Insomecases,youaregoingtocreate
macrosthatareassociatedwithaparticularobjectwithinyourdatabase
environment,suchasaformorabuttononthatform.Inothercases,you
willcreateamacroforageneralscenariowithintheenvironment.When
wegettoChapters5and6,wewillbecreatingacoupleofsimple
macrosandthenconvertingthemintofullVBAcode.Fornow,ifyouclick

onNew(locatedatthetopoftheDatabasewindowintheMacros
category),youwillseeagrid,asshowninFigure1-4.


Figure1-4:TheMacrodesignwindow
Thewindowhastwosections.Thetopsectionallowsyoutodesignan
action,whilethebottomsectionwillbeusedtosetparameters.Asan
example,supposeyouwanttowriteasimplemacrotocloseaform.You
wouldfirstselectClosefromtheActionlistinthetoppartofthegrid
(showninFigure1-5).


Figure1-5:TheActionlistformacros
Onceyouhavedonethat,youneedtoselectwhattoclose.Gotothe
ActionArgumentssectionofthewindowandselectFormintheObject
Typefield,asshownhere.


Fromthereon,allyouneedtodoisaddthenameoftheformobjectyou
areassigningthisactiontoandsavethemacro.Simple,butlimitedin
ability!

Modules
ModulesarewheretheVBAcodeiswrittenandstored.Beginningin
Chapter5,wewillbespendingthebulkofourtimeworkingonourcode
andlearningabouttheVBAenvironment.Forthetimebeing,let’stakea
lookattheVBAEditor(VBE).
WithintheModulescategory,selectNew.Youshouldseethesame
screenasshowninFigure1-6.



Figure1-6:TheVisualBasicEditor
Themainwindow,takingupmostofthescreen,istheCodewindow.The
upper-leftwindowistheProjectwindow,andthelower-leftwindowisthe
Propertieswindow.
NoticetheProjectwindow,whichiswhereyouwillfindallthecode
modulesassociatedwithyourapplication.Forinstance,insophisticated
projects,theVBAcodemaybedividedupovermanymodules.TheVBA
codeassociatedwithaparticularformorreportwillgointoadedicated


modulethatholdsonlythespecializedcodeforthatformorreport;while
codeassociatedwithgeneraloperationswillgointoanentirelydifferent
moduleagain.Wewillbelookingatthisingreaterdetailbeginningin
Chapter5.


TheFutureofMicrosoftAccess
NowthatwehaveseenalittleofthehistoryofAccess,aswellastakena
brieftourofitscurrentlook,let’sgazeintoourcrystalballsandpredict
whereMicrosoftisstronglyindicatingitisgoing.
ThereisnoquestionthattheMicrosoftOfficeenvironment,ofwhich
MicrosoftAccessisapart,servesasthetechnologicalbackboneformost
businessestoday.Microsofthasindicatedthattheywillcontinuetoplace
agreatdealoftheirresearchanddevelopmentintheOfficeenvironment.
Becauseofitseaseofuse,tremendouspower,andrelativelyinexpensive
cost,Accessisnotonlyservingasapersonaldatabaseapplicationtool,
butisincreasinglytakingovertheenterpriserolesofwhatwere,atone
time,reservedformoresophisticatedpackagessuchasSQLServerand
Oracle.Thereisnobetterplacetoseethisthantheincreasinguseof

Accessinbuildingwebsites.
Access2000tookamajorstepforwardwithDataAccessPages.This
meantthatitnowhadamethodtocreateHTMLpagesandbinddatato
them.Asstatedearlier,2002tookthisevenfurtherwiththeabilitytosave
reportsasXMLdocuments.Inaddition,theabilitytosaveaPivotTable
andPivotChartasaweb-baseddocumentwasintroduced.Version2003
thenexpandedtheXMLcapabilities.
Microsofthasmadeonethingabundantlyclear:itisplacingalotofits
futureinthedevelopmentofitsnew.NETenvironment.This
environment,ifitcomestofruition,willallowtighterintegrationofthe
componentsoftheMicrosoftOfficeenvironmentwitheachotheraswell
astheWeb.Thiswillallowpeopletosharedatawithaneasethatisnot
seennow.AttheheartofthatwillbeXMLanditsabilitytointegrate
individualcomponentsontheWeb.
YouwillbeabletocreateadocumentinMicrosoftWord,integratedata
fromAccessintoit,andthensharethedocumentwithwhomeveryou
needtoshareitwithrightontheWeb.
Becauseofthis,developmentwillbeincreasinglyfocusedonweb


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×