Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DoCmd prints to web server printer and not client

Posted on 2011-09-29
3
Medium Priority
?
368 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

876 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