Print Expression

  • Thread starter Thread starter Doug
  • Start date Start date
D

Doug

how do I print an expression directly to the printer in
Access Basic. I believe the equivlent in VB6 would be
printer.print <exp>. Thanks.
 
Doug:

To do that in Access vb, you use the the Open and Print statements. With
Open, you open a port such as LPT1 (without the semicolon) and then send
your output to the port.
 
You can open an unbound report and use the On Page event to print to the
page. For instance to print a monthly calendar for this month, you can
create a report that is at least 7.5 inches wide with the following code:
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
Me.FontSize = 22
'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
 
Back
Top