image - Gadgets drawn by Access using VBA
image - Moon phases from right to left drawn by Access using VBA
Ms Access Gurus

Do you like these gadgets?

Draw Gadgets on Access Reports using VBA

Use VBA to draw gadgets that respond to your data on Access reports. Reports don't have to be boring lists with lots of numbers. Visualize.

Objects can be modified by specifying colors and angles. Graphs are drawn differently depending on the data.

Gadgets are scaled for the available space and positioned where desired. This is a compilation of VBA code you can look at, learn from, and use in your Access projects.

live presentation for Access DevCon 2023

Report Draw Reference on MsAccessGurus

Go to Report Draw Reference for VBA syntax and help for drawing on Access reports.

image - Using VBA to draw Gadgets on Access Reports

Quick Jump

Goto Top  


Download

The link for each gadget has VBA code. You can also download a zipped ACCDB Access database with code for lots of gadgets. DrawGadgets_s4p__ACCDB.zip

Remember to unblock the ZIP file, (remove Mark of the Web) before extracting the file(s). Here are steps to do that: https://msaccessgurus.com/MOTW_Unblock.htm

Goto Top  

Gadgets

Links to pages with information and VBA code

Graphs       Goto Top

Dial

Draw Dials with a needle point to a fraction or percentage value.
image - Dial drawn on an Access report by VBA
Sub Draw_Dial_s4p(oReport As Report _ 
   ,pXCenter As Single,pYCenter As Single _ 
   ,pRadius As Single _ 
   ,Optional psgValue As Variant = -1 _ 
   ,Optional pnColorCenter As Long = vbWhite _ 
   ,Optional psgRatio As Single = 0.6 _ 
   ) 

Gantt chart

Gantt chart to be released in the future It is still in progress. The Project tables it needs to store data, as well as main/subform is done. Also done is the report menu form to launch the Gantt report -- it just isn't hooked up yet. Check my website in the future for a working Gantt chart.

Meter

Meters are great to visualize fractions and percentages. Choose colors, font size, send value.
image - Meter showing 40% drawn on an Access report by VBA image - Meter showing 60% drawn on an Access report by VBA image - Meter showing 80% drawn on an Access report by VBA image - Meter showing 95% drawn on an Access report by VBA
Public Sub Draw_Meter_s4p(poReport As Report _ 
   ,poControl As Control _ 
   ,Optional pdbValue As Double = -1 _ 
   ,Optional pnColor1 As Long = 0 _ 
   ,Optional pnColor2 As Long = 14211288 _ 
   ,Optional psText As String =  "" _ 
   ,Optional piFontSize As Integer = 14 _ 
   ,Optional piFontColor As Long = 0 _ 
   ,Optional piTickColor As Long = gColorWhite _ 
   ) 

Stoplight

Stoplights with green, yellow, or red (or nothing) lit up.
image - Stoplight drawn on an Access report by VBA
Sub Draw_Stoplight_s4p(oReport As Report _ 
   ,oControl As Control _ 
   ,Optional piValue As Integer _ 
   ) 

Objects       Goto Top

Flag

American Flag
image - American Flag drawn on an Access report by VBA
Public Sub FlagAmerican( _  
    pReport As Report _  
    ,ByVal pX As Single ,ByVal pY As Single _  
    ,ByVal pMaxWidth As Single _  
    ,ByVal pMaxHeight As Single _  
    ,Optional ByVal piColorSet As Integer = 0 _  
   ) 

Moon

Draw a Moon given the fraction of light and whether it is waxing or waning. Movement goes from right to left then down and right to left again.
image - 8 Phases of the Moon drawn on an Access report by VBA
Public Sub Draw_Moon_s4p(poReport As Report _ 
      ,pXCenter As Double _ 
      ,pYCenter As Double _ 
      ,ByVal pRadius As Double _ 
   ,Optional pFractionLit As Single = 1 _ 
   ,Optional pbWax As Boolean _ 
   ,Optional pnColorLight As Long = vbWhite _ 
   ,Optional pnColorDark As Long = vbBlack _ 
   ,Optional pnColorOutline As Long = gColorGray _ 
   ) 

Rainbow

Draw full rainbow, or partial rainbows from start to end angles
image - Full rainbow drawn on an Access report by VBA image - Right half rainbow drawn on an Access report by VBA image - Rainbow wedge drawn on an Access report by VBA image - Half rainbow drawn on an Access report by VBA
Public Sub Draw_Rainbow_s4p(poReport As Report _ 
      ,pXCenter As Single _ 
      ,pYCenter As Single _ 
      ,psgRadius As Single _ 
   ,Optional pnColorBackground As Long = vbWhite _ 
   ,Optional psgAngle1 As Single = gZero _ 
   ,Optional psgAngle2 As Single = PI _ 
   ) 

  Rounded Rectangle    

Set outline color, draw width, and amount of rounding for corners — drawn with 4 lines and 4 arcs. When the arc radius is bigger than the shape dimension, you get some interesting effects.
image - Rounded Rectangle with 10% corners drawn on an Access report by VBA image - Rounded Rectangle with 15% corners drawn on an Access report by VBA image - Rounded Rectangle with 50% corners drawn on an Access report by VBA image - Rounded Rectangle with 85% corners drawn on an Access report by VBA image - Rounded Rectangle with corners same radius as width drawn on an Access report by VBA
Sub Draw_RoundRectangle_s4p(oReport As Report _ 
   ,xLeft As Single _ 
   ,yTop As Single _ 
   ,xRight As Single _ 
   ,yBottom As Single _ 
   ,Optional piDrawWidth As Integer = 1 _ 
   ,Optional pnColor As Long = 9868950 _ 
   ,Optional pdbRadiusCorner As Double = 80 _ 
   ) 

  Snowflake    

Set snowflake and background colors, specify angle to rotate
image - Yellow snowflake on blue drawn on an Access report by VBA image - Green snowflake drawn on an Access report by VBA image - Red snowflake drawn on an Access report by VBA image - Snowflake drawn on an Access report by VBA
Public Sub Draw_Snowflake_s4p(poReport As Report _ 
      ,pXCenter As Single _ 
      ,pYCenter As Single _ 
      ,ByVal pRadius As Single _ 
   ,Optional pnColor1 As Long = gColorCyan _ 
   ,Optional pnColor2 As Long = 0 _ 
   ,Optional psgAngleStart As Single = 0 _ 
   ) 

  Snowman    

Set colors for body, hat, buttons, eyes, and outline.
image - SnowMan drawn on an Access report by VBA image - Half snowman drawn on an Access report by VBA image - snowman drawn on an Access report by VBA image - snowman drawn on an Access report by VBA image - snowman drawn on an Access report by VBA
Public Sub Draw_Snowman_s4p(poReport As Report _ 
      ,pXCenter As Single _ 
      ,pYTop As Single _ 
      ,pYHeight As Single _ 
   ,Optional pnColorSnowman As Variant = vbWhite _ 
   ,Optional pnColorHat As Variant = vbBlack _ 
   ,Optional pnColorButton As Variant = vbBlack _ 
   ,Optional pnColorEye As Variant = vbBlack _ 
   ,Optional pnColorLine As Variant = vbBlack _ 
   ) 

Solstice

Draw Earth on its orbit around the sun as its positioned for the December Solstice
image - Solstice drawn on an Access report by VBA
Public Sub Draw_SolsticeDecember_s4p(poReport As Report _ 
      ,pXCenter As Single _ 
      ,pYCenter As Single _ 
      ,pRadiusOrbit As Single _ 
   ,Optional pnColrEarth As Variant = gColorBlueEarth _ 
   ,Optional pnColrAxis As Variant = vbBlack _ 
   ,Optional pnColrOrbit As Variant = gColorGray _ 
   ,Optional pnColrSun As Variant = gColorYellowSun _ 
   ,Optional gColorSunRay As Variant = gColorOrangeRay _ 
   ) 

Tree

easy tree types to draw
image - Lollipop tree drawn on an Access report by VBA image - Pine tree drawn on an Access report by VBA image - Bubble tree drawn on an Access report by VBA
Public Sub Draw_ChristmasTree_s4p(poReport As Report _ 
      ,pXCenter As Single _ 
      ,pYTop As Single _ 
      ,pYHeight As Single _ 
   ,Optional pnColorTree As Variant = gColorGreenTree _ 
   ,Optional pnColorStar As Variant = vbYellow _ 
   ,Optional pnColorStarOutline As Variant = gColorOrange _ 
   ) 

Goto Top  

Reference

Drawing Reference on msAccessGurus

Report Draw Reference for VBA syntax and help for drawing on Access reports.

VBA drawing code with links to more pages with code to draw on your Access reports. If you can imagine it, Access can do it!

Goto Top  

Backstory

I'm fascinated with the power that Access has for drawing on reports ... and it's lots of fun! So this is for all the dreamers that love beautiful things.

Share with others

Here's the link for this page in case you want to copy it and share it with someone:

https://msaccessgurus.com/presentation/Report_Gadgets.htm

or in old browsers:
http://msaccessgurus.com/presentation/Report_Gadgets.htm

Get Help with Access and drawing

Let's connect and team-develop your application together. I teach you how to do it yourself. My goal is to empower you.

While we build something great together, I'll pull in code and features from my vast libraries as needed, cutting out lots of development time. I'll give you lots of links to good resources.

Do you want your reports to be more creative and visual? I'd love to help you. Email me at training@msAccessGurus.com

~ crystal

the simplest way is best, but usually the hardest to see

Goto Top