Tải bản đầy đủ - 0 (trang)
Hack 27. Highlight the Active Control

Hack 27. Highlight the Active Control

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

Togetthistowork,thecontrolsontheformmusthavetheir

SpecialEffectpropertysettoFlat.Youcanuseothersettings

thatallowborderstobedisplayed,suchasShadow,butFlat

seemstoworkbest.WhenShadowisused,andwhenthecontrol

losestheborder,thecontrolstillretainstheshadowpartofthe

border,andthatdoesn'tlookright.

Figure3-26showsthecodemodulebehindtheform.Two

subroutinesareatthetop:active_control_enterand

active_control_exit.Thesesubroutinesrunwhenthey'recalledby

eachcontrol'sEnterandExitevents.Theactive_control_enter

subroutinesetstheactivecontrol,whateveritisatthetime,to

haveathick,redborder.Theborderstylevalueof1indicatesa

solidborder.Theborderwidthvalueof2indicatesathick



border.Redisthensetasthebordercolor.

Theactive_control_exitsubroutinehasjustasinglelineofcode;

itsetsthebordertotransparent.



Figure3-26.Thecodeforturningaborderonand

off



Eachtimeacontrolisentered,itmeansadifferentcontrolwas

justexited.Therefore,thesetwosubroutinesfireinapair.The

Exitroutineturnsofftheborderforonecontrol,andtheEnter

routineturnsitonforanother.



Usingthetechniqueinthishackensuresthatusersclearlysee

whichcontrolisactive.



4.Presentation

Section4.1.Hacks2839

Hack28.SeparateAlphabeticallySortedRecordsinto

LetterGroups

Hack29.CreateConditionalSubtotals

Hack30.UseConditionalFormattingtoPointOut

ImportantResults

Hack31.ProvideaDirectLinktoaReport

Hack32.ProtectIntellectualProperty

Hack33.CreateaSlideshowinAccess

Hack34.PlayVideosinAccessForms

Hack35.ViewReportsEmbeddedinForms

Hack36.PutLineNumbersonaReport

Hack37.ShadeAlternatingLinesonaReport

Hack38.SavePaperbyReducingWhitespace

Hack39.IncludetheDate,Time,andPageCount



4.1.Hacks2839

Ascomprehensiveasadatabasecanbewithprogrammatic

functionality,sophisticatedqueries,andotherbellsand

whistlesyoustillneedtobeabletocommunicatefactsaboutthe

dataitcontains.Thisiswhereformsandreportscomeintoplay.

Adecentdatabasefrontendiscriticalforinteractionbetween

thedatabaseandusmeremortals.Access,ofcourse,shinesin

thisarea.

ThereportdesignerinAccessisafeature-richdevelopment

platform.Itincludesformattingtools,groupingandsorting

options,apalettefullofcontrols,andtheabilitytohookinto

eventsandmusterupsomecoolnesswithVBA.Formsalsohave

events,formattingoptions,andpropertiesgalore.Puttingthem

alltouseisbeyondthescopeofasinglechapter.Soinstead,

thischapterhighlightssomeexcitingwaystoworkwithforms

andreports.

You'vealreadyseenhowtouseformstodisplaydatabase

records.Howaboutusingaformtoplayaslideshowormovies?

"CreateaSlideshowinAccess"[Hack#33]and"PlayVideosin

AccessForms"[Hack#34]showyouhow.

Firstimpressionsareusuallythebest.Makesureyourreports

areeye-poppers.Anumberofhacksinthischapterexplainhow

toprovidesophisticatedgroupingandformattinginreports.

"ProvideaDirectLinktoaReport"[Hack#31]showshowa

busyusercanclickashortcuttoprintareportwithoutfussing

aroundwiththedatabase."ViewReportsEmbeddedinForms"

[Hack#35]explainshowtoincorporatereportsintoforms.



Hack28.SeparateAlphabeticallySorted

RecordsintoLetterGroups



TapthePrefixCharacterspropertytogainnewlayout

possibilities.

Sortingalphabeticallyisnothingnew;infact,it'sratheroldone

ofthestandardpracticeswetakeforgranted.Whenyou'vegot

dozensorhundredsofprintedrecords,though,itcanbe

tedioustoflipthroughreportpageslookingforaparticularline

item,eventhoughthey'reinalphabeticalorder.

Aneatthingtodoistosegregatetherecordsonareport

alphabetically.Figure4-1showsapagefromareportinwhich

sortedrecordslistrepeatedlywithnosuchsegregationor

break.Therecordsaresortednoquestiononthatscorebutthe

layoutmakesitchallengingtofliptotheapproximateareayou

needtofind.



Figure4-1.Areportwitharepetitivelayout



Thereport'sdesignisstraightforward.Thedetailssection

containsthefieldsthatbecomethelineitems.Thereportinthis

formatdoesn'tusegroups,andthatiswhyitismonotonousto

lookat.Figure4-2showsthedesignofthereport.



4.2.1.SegregatingbyLetter

Awaytobreakuptheendlessline-itemlistingistoaddagroup

tothereport.Figure4-3showshowthereport'sdesignhas

beenalteredtoincludeagroup.

ThegroupisbasedontheClientLastNamefield,which,of

course,isthefieldbeingsortedon.Hereareafewkeypoints

abouthowthisgroupisbeingused:



Figure4-2.Areportthatdoesn'tusegrouping

andsorting



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

Hack 27. Highlight the Active Control

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

×