Solved

DoCmd prints to web server printer and not client

Posted on 2011-09-29
3
359 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

A phishing scam that claims a recipient’s credit card details have been “suspended” is the latest trend in spoof emails.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

752 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