tutorial 5 creating advanced queries and enhancing...
TRANSCRIPT
XPXPXPObjectives• Session5.1– Reviewobjectnamingstandards– UsetheLike,In,Not,and&operatorsinqueries– FilterdatausinganAutoFilter– UsetheIIffunctiontoassignaconditionalvaluetoacalculatedfieldinaquery
– Createaparameterquery
NewPerspectivesonMicrosoftAccess2013 2
XPXPXPObjectives(Cont.)• Session5.2– Usequerywizardstocreateacrosstabquery,afindduplicatesquery,andafindunmatchedquery
– Createatopvaluesquery
NewPerspectivesonMicrosoftAccess2013 3
XPXPXPObjectives(Cont.)• Session5.3– Modifytabledesignsusinglookupfields,inputmasks,anddatavalidationrules
– Identifyobjectdependencies– ReviewaLongTextfield’sproperties– Designateatrustedfolder
NewPerspectivesonMicrosoftAccess2013 4
XPXPXPCreatingAdvancedQueriesandEnhancingTableDesign• Case- ChathamCommunityHealthServices
Making theClinicDatabaseEasiertoUse
• UserisinterestedintakingbetteradvantageofthepowerofAccesstomakethedatabaseeasiertouseandtocreatemoresophisticatedqueries
• Useralsoneedsasummarizedlistofinvoiceamountsbycity
NewPerspectivesonMicrosoftAccess2013 5
XPXPXPReviewingtheClinicDatabase
• TheNavigationPanedisplaystheobjectsgroupedbyobjecttype– Eachobjectnamehasaprefixtag—atblprefixtagfortables,aqryprefixtagforqueries,afrmprefixtagforforms,andarptprefixtagforreports
– Allthreecharactersineachprefixtagarelowercase.Thewordimmediatelyafterthethree-characterprefixbeginswithanuppercaseletter
– Usingobjectprefixtags,youcanreadilyidentifytheobjecttype,evenwhentheobjectshavethesamebasename
– Objectnameshavenospaces,becauseotherdatabasemanagementsystemsdonotpermitmakingiteasyduringconversionstothosesystems
NewPerspectivesonMicrosoftAccess2013 8
XPXPXPUsingPatternMatchinaQuery
NewPerspectivesonMicrosoftAccess2013 9
• Apatternmatchselectsrecordswithavalueforthedesignatedfieldthatmatchesthepatternofasimpleconditionvalue
• TheLikecomparisonoperatorselectsrecordsbymatchingfieldvaluestoaspecificpatternthatincludesoneormoreofthesewildcardcharacters:asterisk(*),questionmark(?),andnumbersymbol(#)– Theasteriskrepresentsanystringofcharacters,thequestionmarkrepresentsanysinglecharacter,andthenumbersymbolrepresentsanysingledigit
XPXPXPUsingaList-of-ValuesMatchinaQuery
NewPerspectivesonMicrosoftAccess2013 11
• Alist-of-valuesmatchselectsrecordswhosevalueforthedesignatedfieldmatchesoneoftwoormoresimpleconditionvalues– CouldincludeseveralOrconditionsinthedesigngrid,butthereisaneasierandclearerwaytodothis• TheIncomparisonoperatorletsyoudefineaconditionwithalistoftwoormorevaluesforafieldthatselectandincludethoserecordinthequeryresults
XPXPXPUsingtheNotLogicalOperatorinaQuery
NewPerspectivesonMicrosoftAccess2013 12
• TheNotlogicaloperatornegatesacriterionorselectsrecordsforwhichthedesignatedfielddoesnotmatchthecriterion
XPXPXPUsinganAutoFiltertoFilterData
NewPerspectivesonMicrosoftAccess2013 13
• YoucanusetheAutoFilterfeaturetochooserestrictionsfasterandwithmoreflexibilitythanusingtheconditionandOrlogicaloperator
XPXPXPAssigningaConditionalValuetoaCalculatedField• NullFieldsarefieldsinarecorddoesnotcontainanyinformationatall
• Afieldinarecordthatcontainsanydataatall—evenasinglespace—isnonnull– TocombinenonnullLastNameandFirstNamefields,youcanusetheexpressionLastName&“,“&FirstName• The&(ampersand)operatorisaconcatenationoperatorthatjoinstextexpressions
• Concatenation referstojoiningtwoormoretextfieldsorcharactersencapsulatedinquotes
NewPerspectivesonMicrosoftAccess2013 15
XPXPXPAssigningaConditionalValuetoaCalculatedField(Cont.)• TheIIf(ImmediateIf)functionassignsonevaluetoacalculatedfieldorcontrolifaconditionistrue,andasecondvalueiftheconditionisfalse– TheIIffunctionhasthreeparts:aconditionthatistrueorfalse,theresultwhentheconditionistrue,andtheresultwhentheconditionisfalse
– EachpartoftheIIffunctionisseparatedbyacomma– TheIsNullfunctiontestsafieldvalueoranexpressionforanullvalue;ifthefieldvalueorexpressionisnull,theresultistrue;otherwise,theresultisfalse
NewPerspectivesonMicrosoftAccess2013 16
XPXPXPCreatingaParameterQuery• Aparameterquerydisplaysadialogboxthatpromptstheusertoenteroneormorecriteriavalueswhenthequeryisrun– Thevalueenteredintothepromptcausesthequerytoselectonlythoserecordswithfieldvaluefromthetable
NewPerspectivesonMicrosoftAccess2013 22
XPXPXPCreatingaMoreFlexibleParameterQuery
NewPerspectivesonMicrosoftAccess2013 24
• Mostuserswantaparameterquerytodisplaytherecordsthatmatchtheparametervaluetheuserentersortodisplayallrecordswhentheuserdoesn’tenteraparametervalue– Toprovidethisfunctionality,youcanchangethevalueintheCriteria
boxinthedesigngridforthespecifiedcolumn– PrefixtheLikeoperatortotheoriginalcriterionandconcatenatethe
criteriontoawildcardcharacter
XPXPXPCreatingaCrosstabQuery(Cont.)
NewPerspectivesonMicrosoftAccess2013 28
• ThequickestwaytocreateacrosstabqueryistousetheCrosstabQueryWizard
XPXPXPCreatingaFindDuplicatesQuery
NewPerspectivesonMicrosoftAccess2013 31
• Afindduplicatesqueryisaselectquerythatfindsduplicaterecordsinatableorquery– YoucancreatethistypeofqueryusingtheFindDuplicatesQueryWizard
• AfindduplicatesquerysearchesforduplicatevaluesbasedonthefieldsyouselectwhenansweringtheWizard’squestions
XPXPXPCreatingaFindUnmatchedQuery
NewPerspectivesonMicrosoftAccess2013 32
• Afindunmatchedqueryisaselectquerythatfindsallrecordsinatableorquerythathavenorelatedrecordsinasecondtableorquery– UsetheFindUnmatchedQueryWizardtocreatethistypeofquery
XPXPXPCreatingaTopValuesQuery
NewPerspectivesonMicrosoftAccess2013 34
• Usersmightwanttolimitthenumbertoamoremanageablesizebydisplaying,forexample,justthefirst10records– TheTopValuespropertyforaqueryletsyoulimitthenumberofrecordsinthequeryresults
XPXPXPCreatingaLookupField
NewPerspectivesonMicrosoftAccess2013 37
• Dataentryiseasierifusersdonotneedtorememberthecorrectvaluesforfields
• Alookupfieldletstheuserselectavaluefromalistofpossiblevalue
• UseaLookupWizardfieldinAccesstocreatealookupfieldinatable
XPXPXPUsingtheInputMaskWizard
NewPerspectivesonMicrosoftAccess2013 40
• Aliteraldisplaycharacterisaspecialcharacterthatautomaticallyappearsinspecificpositionsofafieldvalue– likehyphensinasocialsecuritynumber– Toincludethesecharacters,youneedtocreateaninputmask,whichisapredefinedformatusedtoenteranddisplaydatainafield
• AneasywaytocreateaninputmaskistousetheInputMaskWizard whichguidesyouincreatingapredefinedformatforafield– YoumustbeinDesignviewtousetheInputMaskWizard
XPXPXPIdentifyingObjectDependencies
NewPerspectivesonMicrosoftAccess2013 46
• Anobjectdependencyexistsbetweentwoobjectswhenachangetothepropertiesofdatainoneobjectaffectsthepropertiesofdataintheotherobject– DependenciesbetweenAccessobjects,suchastables,queries,andforms,canoccurasrelationshipsorusingaquerytoobtainvaluesfrommorethanonetable.
– Anyformorreportthatusesfieldsfromaqueryisdirectlydependentonthequeryandisindirectlydependentonthetablesthatprovidethedatatothequery
• TheObjectDependenciespanedisplaysacollapsiblelistofthedependenciesamongtheobjectsinanAccessdatabase
XPXPXPDefiningDataValidationRules
NewPerspectivesonMicrosoftAccess2013 48
• DefiningFieldValidationRules– Topreventauserfromenteringanunacceptablevalueinafield,youcancreateafieldvalidationrulethatverifiesafieldvaluebycomparingittoaconstantortoasetofconstants• YoucreateafieldvalidationrulebysettingtheValidationRuleandtheValidationTextfieldproperties• TheValidationRulepropertyvaluespecifiesthevalidvaluesthatuserscanenterinafield.• TheValidationTextpropertyvaluewillbedisplayedinadialogboxifauserentersaninvalidvalue
XPXPXPDefiningDataValidationRules(Cont.)
NewPerspectivesonMicrosoftAccess2013 50
• DefiningTableValidationRules– Tomakesurethatthevalueauserentersisnotlargerthanthemaximumfieldvalue,youcancreateatablevalidationrule
– UsetheValidationRuleandValidationTextpropertiesandsetthesepropertiesforthetableinsteadofforanindividualfield
– Useatablevalidationrulebecausethisvalidationinvolvesmultiplefields
– Afieldvalidationruleisusedwhenthevalidationinvolvesarestrictionforonlytheselectedfield,anddoesnotdependonotherfields
XPXPXPWorkingwithLongTextFields
NewPerspectivesonMicrosoftAccess2013 52
• UseaLongTextfieldtostorelongcommentsandexplanations
• ShortTextfieldsarelimitedto255characters,butLongTextfieldscanholdupto65,535characters– ShortTextfieldslimityoutoplaintextwithnospecialformatting
– LongTextfieldsstoreplaintextsimilartoShortTextfieldsortostorerichtext,whichyoucanselectivelyformatwithoptionssuchasbold,italic,anddifferentfontsandcolors
XPXPXPDesignatingaTrustedFolder
NewPerspectivesonMicrosoftAccess2013 55
• Adatabaseisafile,andfilescancontainmaliciousinstructionsthatcandamageotherfilesonyourcomputerorfilesonothercomputersonyournetwork
• Unlessyoutakespecialsteps,Accesstreatseverydatabaseasapotentialthreattoyourcomputer
• Onespecialstepthatyoucantakeistodesignateafolderasatrustedfolderwhich isafolderonadriveornetworkthatyoudesignateastrustedandwhereyouplacedatabasesyouknowaresafe