VBA script for Report Views (1 Viewer)

Pierre Beauchamp

New member
Local time
Today, 05:26
Joined
Jul 22, 2010
Messages
6
This is a part of the script from Treeview activeX that I have.
Every node in the scrip work fine. My problem I want to see the report call by ( DoCmd.OpenReport reportname:=strObjectName) to be seen in preview mode not to print directly.

I try several combinaison with AcViewpreview with no success. I think the problem is with the way the report is called (reportname:=strObjectName)




Private Sub tvSB_NodeClick(ByVal node As Object)
'User clicked a node

Dim strSwitchboard_SubForm_ToShow As String
Dim strForm_OpenArgs As String

strSwitchboard_SubForm_ToShow = mconMainForm

mstrFormArgs = ""

If UBound(Split(node.KEY, ";")) = 3 Then
Dim strObjectType As String
Dim strObjectName As String
Dim strObjectAddtnl As String

strObjectType = Split(node.KEY, ";")(1)
strObjectName = Split(node.KEY, ";")(2)
strObjectAddtnl = Split(node.KEY, ";")(3)

On Error Resume Next

Select Case strObjectType

Case "Form"
strSwitchboard_SubForm_ToShow = strObjectName
mstrFormArgs = strObjectAddtnl

Case "Form_Dialog"

DoCmd.OpenForm FormName:=strObjectName, windowmode:=acDialog, OpenArgs:=strObjectAddtnl

Case "Report"

DoCmd.OpenReport reportname:=strObjectName

Case "Code"

CallByName CodeContextObject, strObjectName, VbMethod, strObjectAddtnl
 
My problem I want to see the report call by ( DoCmd.OpenReport reportname:=strObjectName) to be seen in preview mode not to print directly.

I try several combinaison with AcViewpreview with no success. I think the problem is with the way the report is called (reportname:=strObjectName)

I will offer some sample code of the TreeView OCX control used to organize reports in an application I developed. Indeed the Reports open in Print Preview mode.

Code:
  'Open the report
  DoCmd.OpenReport ReportName:="CapitalSpendingByProcess", _
                   View:=acViewReport, _
                   WindowMode:=acWindowNormal
 

Users who are viewing this thread

Back
Top Bottom