Changing the size of a rectangle with VBA (1 Viewer)

echorley

Registered User.
Local time
Yesterday, 22:17
Joined
Mar 11, 2003
Messages
131
I have a report where I am trying to change the size and position of a rectangle based on student scores. I have the rectangle in the detail section and the code in the detail section

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

ACTMathPercent = Me.ACT_Math_Percent
PACTHeight = (ACTMathPercent / 100) * 2.5
PACTTop = 3 - (ACTMathPercent / 100) * 2.5

Me.PACT.Width = 0.5
Me.PACT.Height = PACTHeight
Me.PACT.Top = PACTTop
Me.PACT.Left = 1.5

End Sub

However, the rectangle does not appear when I Print Preview the report. Any ideas?
 

vbaInet

AWF VIP
Local time
Today, 03:17
Joined
Jan 22, 2010
Messages
26,374
Set the Border Style property of the box control (or rectangle) to Solid. This can be found on Format tab.
 

SOS

Registered Lunatic
Local time
Yesterday, 19:17
Joined
Aug 27, 2008
Messages
3,517
You need to use TWIPS for your measurements. By saying .5 or 1.5 you are telling it to use 1.5 Twips which 1440 Twips make up an inch.

So try this:

PACTHeight = ((ACTMathPercent / 100) * 2.5) * 1440
PACTTop = (3 - (ACTMathPercent / 100) * 2.5) * 1440

Me.PACT.Width = 0.5 * 1440
Me.PACT.Height = PACTHeight
Me.PACT.Top = PACTTop
Me.PACT.Left = 1.5 * 1440
 

Users who are viewing this thread

Top Bottom