Anybody written code in VB.NET to: 1) show a print preview window of reports
already written and stored in an Access 2002 database; or 2) execute the
print of a report stored in an Access 2002 database?
Thanks,
Dean Slindee 2 13836
Hi,
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strDB As String = String.Format("{0}\Northwind.mdb", GetMyPath)
' Print report
OLEShowReport(strDB, "Invoice", Access.AcView.acViewNormal,
strWhere:="OrderId = 10251")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim strDB As String = String.Format("{0}\Northwind.mdb", GetMyPath)
'Print preview report
OLEShowReport(strDB, "Invoice", strWhere:="OrderId = 10251")
End Sub
Private Function OLEOpenReport(ByVal strDBName As String, _
ByVal strRptName As String, _
Optional ByVal intDisplay As Access.AcView = Access.AcView.acViewNormal, _
Optional ByVal strFilter As String = "", _
Optional ByVal strWhere As String = "") As Boolean
Dim bReturn As Boolean = True
Try
' Create Automation object.
Dim objAccess As New Access.Application
' Open the supplied database.
' Optional parameter at the end of statement
' indicates exclusive mode if set to True...
objAccess.OpenCurrentDatabase(strDBName, False)
' The OpenReport method uses the following arguments...
' Report Name - Name of the report object.
' View - Display in Print Preview or send to printer.
' acNormal - Print report
' acDesign - open report in design (n/a in runtime)
' acPreview - open in preview window
' Filter Name - Name of a saved filter query.
' Where Condition = valid SQL where condition.
objAccess.DoCmd.OpenReport(strRptName, intDisplay, strFilter, _
strWhere, Access.AcWindowMode.acWindowNormal)
' Close Microsoft Access session instance...
objAccess.Quit(Access.AcQuitOption.acQuitSaveNone)
objAccess = Nothing
Catch ex As Exception
bReturn = False
MessageBox.Show(ex.ToString, "Automation", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Try
Return bReturn
End Function
Private Function OLEShowReport(ByVal strDBName As String, _
ByVal strRptName As String, _
Optional ByVal intDisplay As Access.AcView = Access.AcView.acViewPreview, _
Optional ByVal strFilter As String = "", _
Optional ByVal strWhere As String = "") As Boolean
Dim bReturn As Boolean = True
Try
' Create Automation object.
Dim objAccess As New Access.Application
' Open the supplied database.
' Optional parameter at the end of statement
' indicates exclusive mode if set to True...
objAccess.OpenCurrentDatabase(strDBName, False)
' The OpenReport method uses the following arguments...
' Report Name - Name of the report object.
' View - Display in Print Preview or send to printer.
' acNormal - Print report
' acDesign - open report in design (n/a in runtime)
' acPreview - open in preview window
' Filter Name - Name of a saved filter query.
' Where Condition = valid SQL where condition.
objAccess.DoCmd.OpenReport(strRptName, intDisplay, strFilter, _
strWhere)
' Close Microsoft Access session instance...
'objAccess.Quit(Access.AcQuitOption.acQuitSaveNone )
objAccess = Nothing
Catch ex As Exception
bReturn = False
MessageBox.Show(ex.ToString, "Automation", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Try
Return bReturn
End Function
Private Function GetMyPath() As String
Dim fi As New
System.IO.FileInfo(Reflection.Assembly.GetExecutin gAssembly.Location)
Return fi.Directory.ToString
End Function
Ken
------------------------------------
"Dean Slindee" <sl*****@charter.net> wrote in message
news:10*************@corp.supernews.com...
Anybody written code in VB.NET to: 1) show a print preview window of reports
already written and stored in an Access 2002 database; or 2) execute the
print of a report stored in an Access 2002 database?
Thanks,
Dean Slindee
Thanks, Ken
That was exactly what I was looking for. Got it working against a .ade
application.
If the application's Visible property is set to False, then the report can
print without the Access GUI interface showing.
I don't suppose there is any way on a "print preview" mode to show only the
report preview window without the Access host window in the background?
Dean Slindee
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uV**************@TK2MSFTNGP10.phx.gbl... Hi,
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strDB As String = String.Format("{0}\Northwind.mdb", GetMyPath)
' Print report
OLEShowReport(strDB, "Invoice", Access.AcView.acViewNormal, strWhere:="OrderId = 10251")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim strDB As String = String.Format("{0}\Northwind.mdb", GetMyPath)
'Print preview report
OLEShowReport(strDB, "Invoice", strWhere:="OrderId = 10251")
End Sub
Private Function OLEOpenReport(ByVal strDBName As String, _
ByVal strRptName As String, _
Optional ByVal intDisplay As Access.AcView = Access.AcView.acViewNormal, _
Optional ByVal strFilter As String = "", _
Optional ByVal strWhere As String = "") As Boolean
Dim bReturn As Boolean = True
Try
' Create Automation object.
Dim objAccess As New Access.Application
' Open the supplied database.
' Optional parameter at the end of statement
' indicates exclusive mode if set to True...
objAccess.OpenCurrentDatabase(strDBName, False)
' The OpenReport method uses the following arguments...
' Report Name - Name of the report object.
' View - Display in Print Preview or send to printer.
' acNormal - Print report
' acDesign - open report in design (n/a in runtime)
' acPreview - open in preview window
' Filter Name - Name of a saved filter query.
' Where Condition = valid SQL where condition.
objAccess.DoCmd.OpenReport(strRptName, intDisplay, strFilter, _
strWhere, Access.AcWindowMode.acWindowNormal)
' Close Microsoft Access session instance...
objAccess.Quit(Access.AcQuitOption.acQuitSaveNone)
objAccess = Nothing
Catch ex As Exception
bReturn = False
MessageBox.Show(ex.ToString, "Automation", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
Return bReturn
End Function
Private Function OLEShowReport(ByVal strDBName As String, _
ByVal strRptName As String, _
Optional ByVal intDisplay As Access.AcView = Access.AcView.acViewPreview,
_ Optional ByVal strFilter As String = "", _
Optional ByVal strWhere As String = "") As Boolean
Dim bReturn As Boolean = True
Try
' Create Automation object.
Dim objAccess As New Access.Application
' Open the supplied database.
' Optional parameter at the end of statement
' indicates exclusive mode if set to True...
objAccess.OpenCurrentDatabase(strDBName, False)
' The OpenReport method uses the following arguments...
' Report Name - Name of the report object.
' View - Display in Print Preview or send to printer.
' acNormal - Print report
' acDesign - open report in design (n/a in runtime)
' acPreview - open in preview window
' Filter Name - Name of a saved filter query.
' Where Condition = valid SQL where condition.
objAccess.DoCmd.OpenReport(strRptName, intDisplay, strFilter, _
strWhere)
' Close Microsoft Access session instance...
'objAccess.Quit(Access.AcQuitOption.acQuitSaveNone )
objAccess = Nothing
Catch ex As Exception
bReturn = False
MessageBox.Show(ex.ToString, "Automation", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
Return bReturn
End Function Private Function GetMyPath() As String
Dim fi As New System.IO.FileInfo(Reflection.Assembly.GetExecutin gAssembly.Location)
Return fi.Directory.ToString
End Function Ken
------------------------------------
"Dean Slindee" <sl*****@charter.net> wrote in message news:10*************@corp.supernews.com... Anybody written code in VB.NET to: 1) show a print preview window of
reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002 database?
Thanks, Dean Slindee This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joris Kempen |
last post by:
Hi people,
I know that the question has come around sometimes:
How to open an Access Report using ASP and export it to for example
RTF.
I'm...
|
by: Bob Darlington |
last post by:
When I press F1 in print preview, I get the following error message for some
(but not all) reports:
'The expression on Key Down you entered as...
|
by: Robert |
last post by:
I find that most of the time my Access reports are displayed in print
preview mode rather than printed on the printer. Converting these reports
to...
|
by: WJA |
last post by:
A user of one of my databases is having the following problem. When
they open any report in print preview that is formatted for landscape,
it will...
|
by: hamil |
last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview
control, the PageSetup control, and the Print dialog control. The code...
|
by: hgm_kh |
last post by:
My MS-Access application was working perfectly under WIN95/98. When I converted the MS-Access application to run on WIN-XP, some reports which have...
|
by: JoeW |
last post by:
I'm utilizing a database that I created within MS Access within a
program I've created in VB.NET. I am using the VB front end to
navigate the...
|
by: mailjaneen |
last post by:
Hello, can someone help me.
I want to display some fields on a report in print preview (i.e.
instructions), that I don't want to print to the...
|
by: Scorp Scorp |
last post by:
Dear All,
I designed a report, and bound with some data, the retreived data is 7 coloumns.
I set a buttong to open the report in print preview,...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
| |