Drawing Graphics on reports

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

I am using the "Report_Open" event to draw some grids and place some text in
a report.

Everything works great except, the graphice seem to draw very slow. It
takes about 3 seconds to complete the report, but I have used the same
coding in the "Form_Load" event and the graphics execute much faster. Is
this normal? Maybe there is something I am doing wrong, or maybe I am too
pickey. Non the less, can you tell me why this different?
 
I do not understand how you are comparing drawing on a Form versus a
Report since a Form does not support the drawing methods that are
exposed by the Report object.
Show us some code.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Have you tried the code in the OnFormat event of the section concerned, ie.
Detail Section?
Regards
 
OK...I am not drawing the controls on the report I am just relocating them.
I have a grid that builds depending on how many days are in a month.
Each day has a row. The lines already exist on the form but when the form
is called the Report_open event relocates the lines according to how many
days are in the given month. The code given below loops for every day of the
month.

This code also will work in a form but instead of "Report_Open" use
"on_load" the form executes much faster...why?

Option Compare Database
Option Explicit

Dim DaysInMonth As Integer
Dim GridSpacing As Integer
Dim DayCount As Variant
Dim HLineVariable As Object
Dim varHLine As Variant
Dim varDayText As Variant
Dim BoldLineCheckDate As Date

Private Sub Report_Open(Cancel As Integer)
Label2.Caption = Formdate
DaysInMonth = DateSerial(Year(Formdate), Month(Formdate) + 1, Day(Formdate))
_
- DateSerial(Year(Formdate), Month(Formdate), Day(Formdate))
DrawGrid
End Sub

Private Sub DrawGrid()
HLine29.Visible = False
HLine30.Visible = False
HLine31.Visible = False
lblDate29.Visible = False
lblDate30.Visible = False
lblDate31.Visible = False

Border.Width = 7.3333 * 1440
Border.Height = 6.4076 * 1440
Border.Visible = True
GridSpacing = ((Border.Height - 300) / DaysInMonth)
DayCount = 1
BoldLineCheckDate = Formdate

'Draws the Horizintal grid Lines
Do
'Lines
varHLine = "Hline" & DayCount
Controls(varHLine).Top = 300 + (GridSpacing * DayCount)
Controls(varHLine).Visible = 1
'Text
varDayText = "lblDate" & DayCount
Controls(varDayText).Top = 300 + (GridSpacing * DayCount) - 250
Controls(varDayText).Visible = 1
DayCount = DayCount + 1

'makes the line between the saturday and sunday bold

If WeekDay(BoldLineCheckDate) = 7 Then
Me.Controls(varHLine).BorderWidth = 2
End If
BoldLineCheckDate = BoldLineCheckDate + 1
Loop While DayCount < DaysInMonth + 1
'Label14.Caption = FormDate
End Sub
 
I would suggest that you use the Line and Print methods of the report to
draw your calendar. Modify the following to fit your needs:

Private Sub Report_Page()
Dim lngDayHeight As Long
Dim lngDayWidth As Long
Dim datRptDate As Date
Dim intStartWeek As Integer
Dim lngTopMargin As Long
Dim dat1stMth As Date
Dim datDay As Date
Dim lngTop As Long
Dim lngLeft As Long
datRptDate = Date
dat1stMth = DateSerial(Year(datRptDate), Month(datRptDate), 1)
intStartWeek = DatePart("ww", dat1stMth)
lngDayHeight = 2160 'one & half inch
lngDayWidth = 1440 'one inch
lngTopMargin = 720 'half inch
'loop through all days in month
For datDay = dat1stMth To DateAdd("m", 1, dat1stMth) - 1
'find the top and left corner
lngTop = (DatePart("ww", datDay) - intStartWeek) * _
lngDayHeight + lngTopMargin
lngLeft = (Weekday(datDay) - 1) * lngDayWidth
If Weekday(datDay) = 1 Or Weekday(datDay) = 7 Then
Me.DrawWidth = 8
Else
Me.DrawWidth = 1
End If
'draw a rectangle for day
Me.Line (lngLeft, lngTop)-Step _
(lngDayWidth, lngDayHeight), , B
Me.CurrentX = lngLeft + 50
Me.CurrentY = lngTop + 50
Me.Print Day(datDay)
Next


End Sub
 
Duane,
Thanks for the tips. This is very helpful. It seems you have a good grasp
on what I am doing. I am putting together a set of querys, forms and
reports that read records in a scheduling format. Employees and clients. I
am wandering if there are already some good tools or objects that would help
speed up the process. I know about calendar tools by DBI, but I havn't had
much success getting them to read my queries and the technical help that
they provide is very slow and limited. So I am building my own simple forms.
Any ideas?
 
Back
Top