Tải bản đầy đủ - 0 (trang)
Hack 3. Work Fast and Avoid Typos

Hack 3. Work Fast and Avoid Typos

Tải bản đầy đủ - 0trang

Insertanewlineinatextormemofield.



Ctrl-Enter



Enteranewrecord.



Ctrl-+



PastethecontentsoftheWindowsclipboard.



Ctrl-V



Theseshortcutsarequitehandy.Haveyoueverforgottenthe

currentdatewhenyouhadtoenteritinafield?Well,allyou

needtoremembernowisthekeyboardshortcuttoenterthe

currentdate.Whichbringsustothenextpoint…



1.4.2.RememberWheretoReferenceShortcuts

Ittakestimetomemorizeagroupofshortcuts,sothenextbest

thingistoboilitdowntomemorizingjustone.Thetwisthereis

tohavethelistofkeyboardshortcutsavailableonaformthat

youcaneasilydisplayusingyouguesseditakeyboardshortcut.

However,youneedtocreatethisshortcut.



UsingtheAutoKeysMacro

TheAutoKeysmacroletsyouassigndatabaseactionstocustomkeyboard

shortcuts.Youcanassignactionstothefunctionkeys,tokeycombinationssuch

asCtrl-A,andtotheInsertandDeletekeys.Youmustfollowastrictsyntax,

however:acarat(^)representstheCtrlkey,andaplussign(+)representsthe

Shiftkey.Youenterregularkeysverbatim,andyouenclosefunctionkeysand

specialkeys(InsertandDelete)inbraces({}).Hereareafewexamples:

^AsetsanactiontoCtrl-A.

{F9}setsanactiontotheF9functionkey.

+{F9}setsanactiontoShift-F9.

{INSERT}setsanactiontotheInsertkey.



Whenyousetacustomshortcuttoanexistingdefaultshortcut,thecustom

shortcutoverridesthedefaultone.Therefore,youcanoverridecommon

keyboardshortcuts,suchasCtrl-V(paste),andinsteadprovideyourown.

ThesyntaxstatementsareplacedintheMacroNamecolumn,andthe

appropriateactionsaresetintheActioncolumn.Theonlyotherrequirementis

thatthemacroisactuallynamedAutoKeys.



Figure1-7showsaformthatliststhekeyboardshortcuts.The

formisbasedonatablethatholdstheshortcutsandtheir

descriptionsintworespectivefields.Analternativeistojustuse

labelcontrolsinwhichtheshortcutsanddescriptionshavebeen

entered.



Figure1-7.Aquick-referenceformforkeyboard

shortcuts



Afunctionkeyiseasyenoughtoremember.F9isagoodoneto

targetbecauseitisn'tcommonlyused.Bycontrast,F1isn'ta

greatchoicebecauseit'sthestandardforenteringtheHelp

system.Toestablishacustomkeyboardshortcut,usethe

specialAutoKeysmacro.TheAutoKeysmacroisactivatedatstartup

inthesamefashionastheAutoExecmacro.

Figure1-8showstheAutoKeysmacrosetupwithafewcustom

keyboardshortcuts.PressingF9opensthefrmKeyboardShortcuts

formshowninFigure1-7.



Figure1-8.UsingtheAutoKeysmacrotosetup

customkeyboardshortcuts



Hack4.OptimizeDataChanges



Avoidhavingtopropagatedatachangesmanually

throughoutrelatedtablesbyestablishingcascading

updatesanddeletes.

Theoneconstantyoucancountonischange.Whynotplanfor

thiseventualityinyourapplications?Takearealexample:a

customerchangeshername.Ifyouareinbusinesslong

enough,thisissomethingyouwillneedtoaccommodatein

yourdatabase.

Datachangesneedtobepropagatedintwoways.Ifthedata

isn'tusedasatablekeyoraforeignkey,youneedtochange

thedatainalltheplacesitresidesinyourtables.Hopefully,

yourdataresidesinonlyoneplace!Acorrectlymodeled

databaseholdsapieceofdata,suchasacustomername,in

justoneplace.Ifyoudohavesuchapieceofdatainafew

places,however,youpresumablyhaveareasonfordoingthis.

Applicationsgrowovertimeandoftenarehandledbya

successionofdevelopers.Ithappens.

Ifyouhavedatabaseapplicationsinwhichthesamedatais

foundallovertheplace,abrushupondatamodelingisin

order.

Whataboutdatathatexistsintablekeys?Thiscanbea

frustratingchangetopropagateifmanychildtablesusethe

dataastheforeignkey.Thatis,itwillbefrustratingunlessyou

planyourrelationshipswithcascadingupdates.

Whencreatingrelationshipsbetweentables,oneoptionisto

establishcascadingupdates.Figure1-9showstwotablesof

data.ThetblCustomerstableontophascustomerinformation.



Thevaluesinthekeyfield,CustomerID,aretheinitialsofthe

actualcompanynames.InthelowertblInvoicestable,the

CustomerIDservesastheforeignkey.



Figure1-9.Relatedtables



Figure1-10confirmstherelationshipbetweenthetables.Aline

leadsfromtheCustomerIDfieldintblCustomerstothe

CustomerIDfieldintblInvoices.Thenumber1onthe

tblCustomerstablesideofthelineindicatesthattblCustomers

istheparenttable.Theinfinitysymbol( )abovewheretheline

meetsthetblInvoicestableindicatesthattblInvoicesisthechild

table.Thisisaone-to-manyrelationship.ThetblInvoicestable



hasotherrelationshipsaswell.



Figure1-10.TheRelationshipswindow



TheEditRelationshipsdialogbox,showninFigure1-11,is

whereyousetrelationships.Toopenthedialoginthe

Relationshipswindow,double-clickonalinethatconnectstwo

tables.NotetheCascadeUpdateRelatedFieldscheckbox.When

thisboxischecked,changingthevalueinthekeyfieldofthe

parenttableautomaticallychangesthevaluesintherelated

fieldinthechildtable.Thisisagoodthing!Whenacustomer

changeshername,allyouhavetodoischangethevalueinthe

key.Alltheoccurrencesofthevalueinthechildtable

automaticallychangetothenewvalue.

IntheexampleshowninFigure1-9,ifBestEquipmentchanges

itsnametoBestTools,theCustomerIDvalueshouldbe

changedtoBT.MakingthischangeonceinthetblCustomers

tableautomaticallyupdatesallrelatedrecordsinthetblInvoices

table.



AnotheroptionintheEditRelationshipsdialogbox(Figure1-11)isto

establishcascadingdeletes.TheCascadeDeleteRelatedRecords

settingensuresthatwhenyoudeletearecordintheparenttable,all

relatedrecordsinchildtablesarealsodeleted.Whenthisoptionisn't

set,youhavetodeletetherecordsinthechildtablefirst,andthenyou

candeletetherecordsintheparenttable.



Figure1-11.Selectingtousecascadingupdates

anddeletes



Iftheoptiontohavecascadingupdatesisn'tset,youhaveto

changeeachtable'srecordsseparately.Youcandothatonlyif

youremovetherelationshipfirstbecauseAccessdoesn'tletyou

changethevaluesinthekeyfieldineithertableifthereareany

relatedrecords.Tryingtomakeanupdateinthatwayisquite



messy.



Hack5.TransferDataBetweenVersionsof

Access



Saygoodbyetoversionincompatibilityissues.

Microsofthasreleasedmorethanhalfadozenversionsof

Accessovertheyears.Somepeopleandorganizationsbuyinto

eachupgrade,someskiparound,andsomeholdonfordearlife

totheonetheyhavebeenusingsincethepreviouscentury!

Theversiondoesn'tmatterwhenyouoryourorganizationwork

inavacuum,butwhenyouexchangedatawithexternal

companies,versionincompatibilitycanrearitsuglyhead.

Let'ssayyouhaveAccess2003andyousendadatabasefilled

withyourorderstoavendor.ThevendorhasAccess95.Uh-oh!

Thevendorcan'topenyourdatabase.

Oneoftherecentdatatechnologiesinitiatedthroughoutthe

computingworldistheuseofXMLandotherplatform-neutral

protocols.Thispurportedlyremovesdataincompatibility.XMLis

nice,butonlythemostrecentversionsofAccesscanreadXML.

Thewaytosharedataisviaatried-and-true,low-key,low-tech

method:exportandsaveyourdataastext.Althoughtheyvary

intermsofhowtextcanbesaveddelimited,typeofdelimiter

character,textqualifier,fixed-width,andsoonallversionsof

Accesscanreadandwritetextfiles.Figure1-12showsthe

ExportTextWizard,inwhichyousetyourtextexportoptions.

WhenyouinitiatetoexportanAccesstableorqueryandselect

textasthetype,thewizardstartsup.



Figure1-12.UsingtheExportTextWizard



Admittedly,exportingandimportingtextisn'tanideal

approach,especiallywhenyouhavetoexportorimportmany

tablesofdata.Butitsurebeatslosingbusinessbecauseyour

clientcan'topenyourdatabase.

XMLhaspavedthewayforeasydataexchangeamongversions

andsystems.XMLsupportisdecentenoughinAccess2003,

lesssoinAccess2002andAccess2000.Ifworkingwithtext

filesjustdoesn'tseemrightforyourneeds,youcanalwaysuse

XML.AseparateexternalXMLparserdoesthetrick.



1.6.1.SeeAlso

"ProvideCompleteXMLControltoAnyVersionofAccess"



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

Hack 3. Work Fast and Avoid Typos

Tải bản đầy đủ ngay(0 tr)

×