Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Landscape printing of Access Report through VB

Status
Not open for further replies.

himanshum

Programmer
Sep 6, 2002
2
0
0
IN
Dear all

I am looking for a possible way to ave a landscape printing of my Access Report. From the VB file I call the access report and is getting printed in Potrait. I want to change it to landscape.
My code is as follows :

Private Sub cmdRep_Click()

Dim strpath As String
Dim objaccess As Access.Application
Set objaccess = New Access.Application
strpath = App.Path & "\final_ant.mdb"
objaccess.OpenCurrentDatabase strpath
objaccess.DoCmd.OpenReport "final_rep", acViewNormal
objaccess.CloseCurrentDatabase
End Sub

And my report is being called in Access which has the following VB code behind it.

Private Sub Report_Open(Cancel As Integer)

Set cn = New ADODB.Connection
Dim sql As String

If cn.State = 1 Then
cn.Close
End If


cn.Open ("provider=Microsoft.jet.OLEDB.4.0;Data Source=c:\xxx.mdb;" & "Persist Security Info=False")

Set rs = New ADODB.Recordset
rs.Open "select * from report_data", cn, adOpenKeyset, adLockOptimistic
rs.MoveFirst

Set rs1 = New ADODB.Recordset
rs1.Open "select * from duplicate where new_card_no ='" & rs.Fields("cardno") & "'", cn, adOpenKeyset, adLockOptimistic
rs.MoveFirst

End Sub
*********************************************

Please help me getting the landscape printout of this report.

Thanks in advance
Himanshu Madan.
 
I know this sounds simplistic but can you save the report in landscape then call it from VB?

Binky ::)
><>
 
Either save 2 identical reports, one in Landscape and one in Portrait,
or,
Allow the user to select how they want to print the report.
You would need to open the report in PrintPreview though (acPreview).

Then somewhere in code after the report has been called up with:
objaccess.DoCmd.OpenReport &quot;final_rep&quot;, acPreview

add the following to bring up the page setup screen:

On Error Resume Next
.RunCommand acCmdPageSetup

Sometimes, when the user clicks cancel, an Access error message comes up, you need the &quot;On Error Resume Next&quot; or an error handler routine.

Please note that no VB code will be executed after calling this until the page setup window is closed (the page setup is a vbModal form of Access) [/b][/i][/u]*******************************************************[sub]
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
pgk:
I do not think that will work in this case.
The report may not always be printing to the default printer.... [/b][/i][/u]*******************************************************[sub]
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top