473,756 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run an Access report in a VB .Net application

I'm in the process of migrating a MS Access 2003 application to VB .Net
(2005). How can I run the reports in Access from the VB application?
--
Tony
Aug 11 '06 #1
3 6471
Tony,

Probably with Office integration, be aware that the end users needs all full
licence of MS office access for that.

Cor

"Tony A." <To***@discussi ons.microsoft.c omschreef in bericht
news:0E******** *************** ***********@mic rosoft.com...
I'm in the process of migrating a MS Access 2003 application to VB .Net
(2005). How can I run the reports in Access from the VB application?
--
Tony

Aug 12 '06 #2
I'm in the process of migrating a MS Access 2003 application to VB .Net
(2005). How can I run the reports in Access from the VB application?
Try the following. It requires Microsoft's Access to be installed on the
user's system. (Watch out for wordwrap.)

Public Sub PrintAccessRepo rt(ByVal sReportName As String, Optional ByVal
sQryName As String = "", Optional ByVal sSQL As String = "")

Dim oAccess As New Access.Applicat ionClass

oAccess.Visible = True

oAccess.OpenCur rentDatabase(gs CurLocation & gsCurDatabase)

oAccess.DoCmd.M inimize()

'Create new query if needed

If sQryName.Length 0 And sSQL.Length 0 Then

Try

'oAccess.Curren tDb.QueryDefs.D elete(sQryName)

oAccess.DoCmd.D eleteObject(Acc ess.AcObjectTyp e.acQuery, sQryName)

Catch

'Close and reopen the Access object if above statement failed

oAccess.Visible = False

oAccess.Quit(Ac cess.AcQuitOpti on.acQuitSaveNo ne)

System.Runtime. InteropServices .Marshal.Releas eComObject(oAcc ess)

oAccess.Visible = True

oAccess.OpenCur rentDatabase(gs CurLocation & gsCurDatabase)

oAccess.DoCmd.M inimize()

End Try

oAccess.Current Db.CreateQueryD ef(sQryName, sSQL)

End If

'Preview the report

oAccess.DoCmd.O penReport(sRepo rtName, Access.AcView.a cViewPreview, , ,
Access.AcWindow Mode.acDialog)

'Close the Access Instance

If Not oAccess Is Nothing Then

' Call Access Quit method without saving any changes.

oAccess.Quit(Ac cess.AcQuitOpti on.acQuitSaveNo ne)

' Use Marshal class' ReleaseComObjec t to release the Access instance.

System.Runtime. InteropServices .Marshal.Releas eComObject(oAcc ess)

' Dereference the oAccess variable.

oAccess = Nothing

End If

End Sub

------------------------------------------------------------------------
George Shubin Custom Software Development
dX Software Systems Database Applications
Ph: 503-981-6806 Fax: 503-982-0120
www.dxonline.com ge****@dxonline .com
------------------------------------------------------------------------

"Despite efforts by government to prevent concentration in industry, the
regulators are bringing us to the point where only the largest companies can
survive." -- Henry Ford
Aug 12 '06 #3
Just interested in knowing where there might be more info/articles/tutorials
on 'Access Automation' using VBE (i.e., other aspects of this - not just
reports)??

--
Thanks!
Soddy
"George Shubin" wrote:
I'm in the process of migrating a MS Access 2003 application to VB .Net
(2005). How can I run the reports in Access from the VB application?

Try the following. It requires Microsoft's Access to be installed on the
user's system. (Watch out for wordwrap.)

Public Sub PrintAccessRepo rt(ByVal sReportName As String, Optional ByVal
sQryName As String = "", Optional ByVal sSQL As String = "")

Dim oAccess As New Access.Applicat ionClass

oAccess.Visible = True

oAccess.OpenCur rentDatabase(gs CurLocation & gsCurDatabase)

oAccess.DoCmd.M inimize()

'Create new query if needed

If sQryName.Length 0 And sSQL.Length 0 Then

Try

'oAccess.Curren tDb.QueryDefs.D elete(sQryName)

oAccess.DoCmd.D eleteObject(Acc ess.AcObjectTyp e.acQuery, sQryName)

Catch

'Close and reopen the Access object if above statement failed

oAccess.Visible = False

oAccess.Quit(Ac cess.AcQuitOpti on.acQuitSaveNo ne)

System.Runtime. InteropServices .Marshal.Releas eComObject(oAcc ess)

oAccess.Visible = True

oAccess.OpenCur rentDatabase(gs CurLocation & gsCurDatabase)

oAccess.DoCmd.M inimize()

End Try

oAccess.Current Db.CreateQueryD ef(sQryName, sSQL)

End If

'Preview the report

oAccess.DoCmd.O penReport(sRepo rtName, Access.AcView.a cViewPreview, , ,
Access.AcWindow Mode.acDialog)

'Close the Access Instance

If Not oAccess Is Nothing Then

' Call Access Quit method without saving any changes.

oAccess.Quit(Ac cess.AcQuitOpti on.acQuitSaveNo ne)

' Use Marshal class' ReleaseComObjec t to release the Access instance.

System.Runtime. InteropServices .Marshal.Releas eComObject(oAcc ess)

' Dereference the oAccess variable.

oAccess = Nothing

End If

End Sub

------------------------------------------------------------------------
George Shubin Custom Software Development
dX Software Systems Database Applications
Ph: 503-981-6806 Fax: 503-982-0120
www.dxonline.com ge****@dxonline .com
------------------------------------------------------------------------

"Despite efforts by government to prevent concentration in industry, the
regulators are bringing us to the point where only the largest companies can
survive." -- Henry Ford
Dec 3 '06 #4

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

Similar topics

3
23876
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how to use a database table but all I want to do now is to click a command button to display this access report. Any suggestions please ?????
2
4198
by: Matt Sogla | last post by:
I was wondering if it is possible to take a canned report ( on an Access database (Access XP version), and then be able to write a C# application that will make a call to the canned report in Access and print it (just as you would print the report while in Access)? If so, could you give me an example so I could follow the syntax. Printing from a C# application isn't as graceful as going into Access and just running the report and...
7
8868
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
11
6600
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
2
14129
by: Dean Slindee | last post by:
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
3
3714
by: Newbie | last post by:
This is my first try at running Access Report by Visual Basic I have the following code in my button press event: ' 2 - Show print preview objAccess.DoCmd.OpenReport "Invoices", 2, , ".=" & _ intCurrentInvoice objAccess.DoCmd.Maximize
8
6389
by: jbonifacejr | last post by:
This is my first day here, so please be patient. I do not know how to search very well so the search I tried to get the answer showed me topics from the year 2000 and they really don't cover what I want. I am trying to open MSAccess from ASP..I guess I would use server.createobject("Access.Application") OK, but where do i go from there to run a report and have it print to the default printer?
16
6533
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 information, but want to be able to print a report, that I've also created within MS Access. I've attempted using the Access.Application instance, but I get errors when it tries to load the database. Just wondering if anyone has any experience with this, and what I should do. Thanks for any...
0
2382
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and handle the situations after the Access Close button has been clicked. I have been largely...
5
5893
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and handle the situations after the Access Close button has been clicked. I have been largely...
0
9287
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10046
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.