Programming A Watermark

P

PC User

I'm trying to make a function that creates a watermark on an access
report. I have A2K and the function is to be called when a report is
openned. Call Watermark(Me). I almost have it working, but I get an
error "You entered an expression that has an invalid reference to the
property ScaleMode." I can't find what is wrong. Can someone help
me?

==========================================
Public Function Watermark(rpt As Report)
Dim strMessage As String
Dim lngHorSize As Long
Dim lngVerSize As Long
Debug.Print rpt.Name
strMessage = "DRAFT"
With rpt
'Set scale to pixels, and set FontName and
'FontSize properties.
..ScaleMode = 3
..FontName = "Courier"
..FontSize = 48
..ForeColor = 12632256
' Horizontal width.
lngHorSize = .TextWidth(strMessage)
' Vertical height.
lngVerSize = .TextHeight(strMessage)
' Calculate location of text to be displayed.
..CurrentX = (.ScaleWidth / 2) - (lngHorSize / 2)
..CurrentY = (.ScaleHeight / 2) - (lngVerSize / 2)
' Print text on Report object.
..Print strMessage
End With
End Function
==========================================

Thanks,
PC
 
B

Brendan Reynolds

I'm not 100% sure of this, but I think the ScaleMode property can only be
set in the Print event procedure. Your code works for me in the Print event
procedure of the detail section.
 
P

PC User

I did find the resolution. The function has to be called from the On
Print event of the report section where you want the watermark to
appear. I was using the On Open event and that didn't work.

PC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top