473,394 Members | 1,935 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Printer Orientation and PrtDevMode MSDN example not working

Hi All,

I am using the PrtDevMode property of a report open in design view to
try and flip the orientation of the report between Portrait and
Landscape in a user control box before the report is opened. I pretty
much used the example out of the help verbatim and Im not having any
luck with it working. I thought originally that because some of my
controls (Lines) extended to the right margin of the report (designed
in Landscape) that Access wouldn't flip it. I shortened the controls
yet the page still always shows up in Landscape. Here is my code as it
stands.

Synopsis: Using an existing report template, I copy the template to a
new report name. Open the report in design view, set the printer
orientation, render some dynamic controls (columns), set the
recordsource, save the report and then open it in design mode.
On Error Resume Next
DoCmd.DeleteObject acReport, "_AutoReport"
On Error GoTo 0

DoCmd.CopyObject , "_AutoReport", acReport, "_SemiAnnualMaster"
DoCmd.OpenReport "_AutoReport", acViewDesign
Set rpt = Reports("_AutoReport")

rpt.RecordSource = ""

'Setup our printer page layout here
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.intOrientation = 1
LSet DevString = DM
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra

'Calculate our spacing on controls...
Dim lngWorkingSpace As Long
Dim lngColumnWidth As Long
Dim lngColumnCount As Long
lngWorkingSpace = rpt.Width - LEFT_DATA_MARGIN
lngColumnWidth = lngWorkingSpace / Me.AnalyteColumnCount

lngColumnCount = 1

If IsNumeric(Me.AnalyteColumnCount) Then
For i = 1 To Me.ColumnList.ListCount
If ColumnList.Column(3, i) = Me.ReportGroup Then
'create a label or possibly many
Dim Labels() As String
If IsNull(ColumnList.Column(4, i)) Then
Set ctlLabel = CreateReportControl(rpt.Name, acLabel,
acPageHeader, , , LEFT_DATA_MARGIN + ((lngColumnCount - 1) *
lngColumnWidth), 780 + (210), lngColumnWidth, 210)
ctlLabel.Caption = ColumnList.Column(0, i)
If Not IsNull(Me.ColumnAlignment) Then
ctlLabel.TextAlign = Me.ColumnAlignment
End If
Else
Labels = Split(ColumnList.Column(4, i), "<p>", ,
vbTextCompare)
For j = 0 To Database.GetUpper(Labels, 1) - 1
Set ctlLabel = CreateReportControl(rpt.Name,
acLabel, acPageHeader, , , LEFT_DATA_MARGIN + ((lngColumnCount - 1) *
lngColumnWidth), 780 + (210 * j), lngColumnWidth, 210)
ctlLabel.Caption = Labels(j)
If Not IsNull(Me.ColumnAlignment) Then
ctlLabel.TextAlign = Me.ColumnAlignment
End If
Next j
End If

'create a text box
Set ctlTextBox = CreateReportControl(rpt.Name, acTextBox,
acDetail, , ColumnList.Column(1, i), LEFT_DATA_MARGIN +
((lngColumnCount - 1) * lngColumnWidth), 0, lngColumnWidth, 210)
If Not IsNull(Me.DataFormat) And Me.DataFormat <> "" Then
ctlTextBox.Format = Me.DataFormat
End If
If Not IsNull(Me.ColumnAlignment) Then
ctlTextBox.TextAlign = Me.ColumnAlignment
End If
ctlTextBox.BorderStyle = 0
ctlTextBox.FontName = "Arial"
lngColumnCount = lngColumnCount + 1
End If
Next i
End If

rpt.RecordSource = strSQL

DoCmd.Close acReport, rpt.Name, acSaveYes
DoCmd.OpenReport "_AutoReport", acViewPreview

Any thoughts on which Access quirk is keeping this from flipping? thank
you much.

ja

Nov 13 '05 #1
2 4627
Try this :
http://msdn.microsoft.com/library/de...0_printers.asp
<je**@askey.org> a écrit dans le message de news:
11*********************@f14g2000cwb.googlegroups.c om...
Hi All,

I am using the PrtDevMode property of a report open in design view to
try and flip the orientation of the report between Portrait and
Landscape in a user control box before the report is opened. I pretty
much used the example out of the help verbatim and Im not having any
luck with it working. I thought originally that because some of my
controls (Lines) extended to the right margin of the report (designed
in Landscape) that Access wouldn't flip it. I shortened the controls
yet the page still always shows up in Landscape. Here is my code as it
stands.

Synopsis: Using an existing report template, I copy the template to a
new report name. Open the report in design view, set the printer
orientation, render some dynamic controls (columns), set the
recordsource, save the report and then open it in design mode.
On Error Resume Next
DoCmd.DeleteObject acReport, "_AutoReport"
On Error GoTo 0

DoCmd.CopyObject , "_AutoReport", acReport, "_SemiAnnualMaster"
DoCmd.OpenReport "_AutoReport", acViewDesign
Set rpt = Reports("_AutoReport")

rpt.RecordSource = ""

'Setup our printer page layout here
strDevModeExtra = rpt.PrtDevMode
DevString.RGB = strDevModeExtra
LSet DM = DevString
DM.intOrientation = 1
LSet DevString = DM
Mid(strDevModeExtra, 1, 94) = DevString.RGB
rpt.PrtDevMode = strDevModeExtra

'Calculate our spacing on controls...
Dim lngWorkingSpace As Long
Dim lngColumnWidth As Long
Dim lngColumnCount As Long
lngWorkingSpace = rpt.Width - LEFT_DATA_MARGIN
lngColumnWidth = lngWorkingSpace / Me.AnalyteColumnCount

lngColumnCount = 1

If IsNumeric(Me.AnalyteColumnCount) Then
For i = 1 To Me.ColumnList.ListCount
If ColumnList.Column(3, i) = Me.ReportGroup Then
'create a label or possibly many
Dim Labels() As String
If IsNull(ColumnList.Column(4, i)) Then
Set ctlLabel = CreateReportControl(rpt.Name, acLabel,
acPageHeader, , , LEFT_DATA_MARGIN + ((lngColumnCount - 1) *
lngColumnWidth), 780 + (210), lngColumnWidth, 210)
ctlLabel.Caption = ColumnList.Column(0, i)
If Not IsNull(Me.ColumnAlignment) Then
ctlLabel.TextAlign = Me.ColumnAlignment
End If
Else
Labels = Split(ColumnList.Column(4, i), "<p>", ,
vbTextCompare)
For j = 0 To Database.GetUpper(Labels, 1) - 1
Set ctlLabel = CreateReportControl(rpt.Name,
acLabel, acPageHeader, , , LEFT_DATA_MARGIN + ((lngColumnCount - 1) *
lngColumnWidth), 780 + (210 * j), lngColumnWidth, 210)
ctlLabel.Caption = Labels(j)
If Not IsNull(Me.ColumnAlignment) Then
ctlLabel.TextAlign = Me.ColumnAlignment
End If
Next j
End If

'create a text box
Set ctlTextBox = CreateReportControl(rpt.Name, acTextBox,
acDetail, , ColumnList.Column(1, i), LEFT_DATA_MARGIN +
((lngColumnCount - 1) * lngColumnWidth), 0, lngColumnWidth, 210)
If Not IsNull(Me.DataFormat) And Me.DataFormat <> "" Then
ctlTextBox.Format = Me.DataFormat
End If
If Not IsNull(Me.ColumnAlignment) Then
ctlTextBox.TextAlign = Me.ColumnAlignment
End If
ctlTextBox.BorderStyle = 0
ctlTextBox.FontName = "Arial"
lngColumnCount = lngColumnCount + 1
End If
Next i
End If

rpt.RecordSource = strSQL

DoCmd.Close acReport, rpt.Name, acSaveYes
DoCmd.OpenReport "_AutoReport", acViewPreview

Any thoughts on which Access quirk is keeping this from flipping? thank
you much.

ja

Nov 13 '05 #2
That worked like a charm. Thank you. Much Much Easier than the 'old'
way.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bruce Adams | last post by:
I am using VB6 SP6. I have an application that prints charts. Specifically, it prints line charts of plant process information nightly. The code is a mix of API calls and Printer methods. I am...
3
by: Rick Collard | last post by:
I have been experimenting with the new Printer object in Access 2002 and discovered some unexpected database bloat. Simply assigning the same value to a property of a report's Printer object will...
3
by: bla | last post by:
Hello all, Does anybody have working sample VBA code to change printerdriver in a report and to get a list of available drivers and there functionality? It is for Access 2000. This version of...
2
by: tom | last post by:
Hi All, Using VBA, I would like to be able to examine a report in design mode and determine its page orientation (landscape or portrait). I do not want to change the orientation. I'm fine...
5
by: Hank | last post by:
My Access 2000 code has been running for several years in our main plant. Now we need to install it, as a stand-along application, at remote sites, some of which are out of state. My problem is...
1
by: Karthic | last post by:
When i right click on the .rpt file in the VS 2003, i see a property printer setting. It says "No printer" on the top and there is option to select printer and paper settings etc.. I want to...
2
by: veerleverbr | last post by:
Hi, Can anyone give me sample code on how to use de info in PrtDevMode en PrtDevNames of Access from within VB.NET? This is how it's done in VB6:...
3
by: Giovanni Benedetti | last post by:
Hi everybody, sorry for my English first of all. I've an ASP page (ASP 3.0) used on an intranet which fill up some particular Mail sheets getting data from a database. Those pre-compiled sheets...
4
by: MLH | last post by:
How do I ensure my reports are being printed in max resolution of 1200dpi ? That is, can Access control the setting?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.