Solved

DoCmd prints to web server printer and not client

Posted on 2011-09-29
3
351 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now