Solved

DoCmd prints to web server printer and not client

Posted on 2011-09-29
3
354 Views
Last Modified: 2012-05-12
I created a connection to the access database and configured IIS along with permissions and app pool settings. When I run this code from the client machine via web browser, it calls the report and prints it to the default printer of the web server and not the client's printer.
Obviously, I cannot do this where I need to print to the clients printer. Any ideas?


Imports System.Data.OleDb
Imports System.Data
Imports Microsoft.Office.Interop.Access
Imports Microsoft.Office.Interop.Access.Dao
Imports Microsoft.Office.Core
Partial Class jobreview
    Inherits System.Web.UI.Page
       Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Dim MSA As New Microsoft.Office.Interop.Access.Application()
        Dim cboJobNums As String
         cboJobNums = Session("NewJob")

        MSA.Application.Visible = False
        MSA.OpenCurrentDatabase("path to db", False)

        MSA.Application.DoCmd.OpenReport("rptJobFormPrint_EDBS", AcView.acViewNormal, WhereCondition:="[Jobs].[Job No]= '" & cboJobNums & "'")

        MSA.Application.DoCmd.Close()

        MSA.CloseCurrentDatabase()


    End Sub
End Class
0
Comment
Question by:BKennedy2008
  • 2
3 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36817834
Is outputting the report to a PDF an option?

Then when they open the PDF on the web page and select print, it should print locally.
Or give then an option to DL the resulting pdf file

MSA.Application.DoCmd.OpenReport("rptJobFormPrint_EDBS", AcView.acViewNormal, WhereCondition:="[Jobs].[Job No]= '" & cboJobNums & "'")
MSA.Application.    DoCmd.OutputTo acOutputReport, "rptJobFormPrint_EDBS", acFormatPDF, "H:\PDFs\SomeName.pdf"
'Some code to display the PDF on a web form, or give the user the option to DL it.

(Note, this requires Access 2007 with the PDF add-in installed, or Access 2010)
For Access formats for 2003 and below see this utility:
http://www.lebans.com/reporttopdf.htm

JeffCoachman
0
 
LVL 26

Expert Comment

by:Nick67
ID: 36818048
I hadn't thought about that when we worked your report :(
And I am not sure how ASP.NET does printing in general, if there are ways for the server to seize the default client printer or whether it is driven strictly by the client
As Jeff said, outputting to pdf and linking and display that pdf is probably simplest.

I have VBA code that creates PDF's and dynamically writes simple web pages to display them.
It then emails the client a link to the newly created page.

I suspect it is not beyond your abilities to create a link to a PDF that gets created dynamically with some unique session-based name and then gets cleaned up when the session ends.
0
 
LVL 26

Accepted Solution

by:
Nick67 earned 250 total points
ID: 36987440
Your solution may be here
http://stackoverflow.com/questions/270674/print-pdf-from-asp-net-without-preview
Create the pdf on the server using @boag2000's syntax
MSA.Application.    DoCmd.OutputTo acOutputReport, "rptJobFormPrint_EDBS", acFormatPDF, "H:\PDFs\SomeName.pdf"
Then, link that pdf in an IFRAME and print it client side.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question