将水印添加到 Access 报告页面 [英] Adding watermark to a Access report page

查看:77
本文介绍了将水印添加到 Access 报告页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用图片"属性向 Access 报告添加水印,但遇到了问题.以下代码有效,并且在预览和打印报告时显示/打印图像,但在直接从宏(屏幕上不可见)打印报告时不起作用.GrandTotal"是报表上的一个绑定文本框,它是记录源中某个字段的总和.如果您有任何关于从打印预览和打印宏打印水印的建议,我将不胜感激.

I am trying to add a watermark to an Access report using the "Picture" property and have run into an issue. The following code works and the image is displayed/printed when the report is previewed and printed but does not work when the report is directly printed from a macro (nothing visible on-screen). "GrandTotal" is a bound text box on the report that is the sum of a field in the record source. I would appreciate any suggestion to print the watermark from both the print preview and the print macro.

Private Sub Report_Load
' put up the watermark if needed

    If GrandTotal.Value < 2000 Then
        Me.Picture = <<picture file name including full path>>
    End If
End Sub

推荐答案

由于您在打印报告时从未将其呈现到屏幕上,因此永远不会触发 open/load 事件,因为它们从未被使用.另一种方法是在打印预览中打开报告并使用 OpenArgs 表示您要打印它

Since you are printing the report without it ever rendering to the screen the open/load events are never fired because they are never used. An alternative could be to open the report in print preview and use the OpenArgs to indicate you want to print it

Private Sub SomeButton_Click()
    DoCmd.OpenReport "DetailView", acViewPreview, , , acHidden, "Print"
End Sub

然后做你正常的加载工作

then do your normal loading stuff

Private Sub Report_Load
' put up the watermark if needed

    If GrandTotal.Value < 2000 Then
        Me.Picture = <<picture file name including full path>>
    End If
End Sub

加载完成后,您的表单将激活,此时您可以打印

and when the loading is done your form will Activate which is when you can print

Private Sub Report_Activate()
    If Me.OpenArgs = "Print" Then
        On Error GoTo ErrorHandler

        DoCmd.OpenReport "Report1", acViewPreview
        'Opens print dialog for current screen (report in this case):
        DoCmd.RunCommand acCmdPrint
    End If
    DoCmd.Close
ErrorHandler:
    If Err.Number <> 0 And Err.Number <> 2501 Then
        MsgBox "Error: " & Err.Number & vbNewLine & Err.Description
        Exit Sub
    End If
End Sub

该表单从未显示,所以看起来您之前已经设置过它,但加载/打开事件会像平常一样触发,因为实际上已呈现报告.

The form is never shown so it looks like you had it set up before but the load/open events will fire like normal because the report is actually rendered.

这篇关于将水印添加到 Access 报告页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆