Solved

DoCmd prints to web server printer and not client

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
OfficeMate Freezes on login or does not load after login credentials are input.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

707 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

17 Experts available now in Live!

Get 1:1 Help Now