Posted on 2014-09-05
Last Modified: 2014-09-13
Good Afternoon,

 I am having a very bizarre issue and I was wondering if someone can shed some light on the problem.

 We have an MS access application that our customers use through Terminal Server / Remote Desktop Service (In this case to a Windows 2012 Server but the bug occurs in Windows 2008 and 2003 Server as well).

 When the customer connects the first time to the ms access application they can print to redirected printers normally. They usually stay connected to the server however sometimes they may need to close their rd connection or they may lose rd connection momentarilly to the server until it automatically reconnects.

 The problem we are having is that on reconnection not all the printers are available in the MS Access Application. Very frequently, only a few printres are available. Enumerating Application.Printers only returns some printers but not all. In order to temporarily resolve the issue, our customer needs to restart his MS Access application for the printers to reappear.

Even more weird is that all printers appear in the Devices and Printers section on the server and you can test print without a problem.

 I have done a few test in VBA and realized that when the rd connection is restarted, the Printers Collection Object only enumerates some printers and not all and I think this is where the issue is coming from. However I don't know if there's a way to "reset" or "refresh" the object without exiting the application. Set Application.Printer = Nothing doesn't work.

 The reason why I can't just simply close and open the ms application is because Terminal Server is configured to only open the specified ms access program so once it's closed, the connection is closed as well and it's a huge burden on the customer to restart his Remote Desktop connection every time.

I was reading on the subject and read to keep a list of the printers in a temp table as soon as the application starts so that if the application loses some printers we'll have a list of them saved and can use them. However, I've tried doing that and something like Application.Printer = Application.Printers("name of saved printer") returns an Error 5, Invalid procedure call or argument. I guess if the printer is not in the collection then it can't work.

 If anyone can help or has experienced this please let me know how to resolve this!!

Thanks :)
Question by:TSIsolutions
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
  • 3
  • 2
LVL 85
ID: 40306479
I would assume this has a lot more to do with the way TS or Citrix handles the printers than with Access. Simply put, if the printers are not available, then Access can't connect to them. They most likely come available after the Access application starts up.

You could use your temporary table idea, and have a routine that simply cycles through the values until they all become valid. You can just ignore the error (with an empty error handler, basically) and keep going until they all "work", or until it's time to give up.

Author Comment

ID: 40306580
Hi Scott,

Thanks for the quick reply.
We also thought it was a time issue. So we waited for all the printer to be redirected. We can see them in the Printer Folder, but they are not accessible in the Printer Collection within Ms Access. We think that the Printer Collection feeds of the winspool API somehow and there's a disconnect somewhere.

Thanks again for your help.
LVL 58
ID: 40306593
<<I would assume this has a lot more to do with the way TS or Citrix handles the printers than with Access. >>

  Yes, it's a very common problem.   This is not limited to Access, other apps have the same issue.   When a session disconnects, the printer and queue are deleted.  

<<Even more weird is that all printers appear in the Devices and Printers section on the server and you can test print without a problem.>>

<< The reason why I can't just simply close and open the ms application is because Terminal Server is configured to only open the specified ms access program so once it's closed,>>

 Tough problem in that I'm not aware of anyway to tell Access to refresh it's printers collection without stopping and re-starting it.

  Note sure if it would get you any further or not, but there is a setting to only map the default client printer.   If you did that, and left the report set for "default printer" rather then naming a specific printer, that might work after a reconnect.

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.


Accepted Solution

TSIsolutions earned 0 total points
ID: 40308205
MS ACCESS Printer Redirection Issue [SOLVED]!!!

Hi everyone,

After days of testing, we realized that if we change the default printer in the printer folder, then returned and enumerated via VBA the list of available printers in the Printer collection in Ms Accesss, all the printers would return!
It looks like the Printer Collection refreshes or winspool communicates the changes to the Printer Collection and, after the default printer change, are now available.
All we had to do next is program the workaround using the winspool API to mimic the act of changing the default printer.
In order to make sure that this would work, we created a generic text driver printer (LPT1) on the server and named it "DO NOT REMOVE".
Next , we created the code below which would save the current default printer, change it to "DO NOT REMOVE" and back to the default printer.
Here's the sample code if you're interested:

' Declaration API call to Get Default Printer for fReset Printer
Public Declare Function GetDefaultPrinter Lib "winspool.drv" Alias "GetDefaultPrinterA" (ByVal sPrinterName As String, lPrinterNameBufferSize As Long) As Long
' Declaration API call to Change Default Printer fReset Printer
Private Declare Function SetDefaultPrinter Lib "winspool.drv" Alias "SetDefaultPrinterA" (ByVal pszPrinter As String) As Long
Function fResetRDPPrinters()

    Dim sLen As Long
    Dim hResult As Long
    Dim GetDP As String
    Dim sDefPrinter As String
    GetDP = Space$(255)
    sLen = 255
    hResult = GetDefaultPrinter(ByVal GetDP, sLen)
    If hResult <> 0 Then
        sDefPrinter = Left(GetDP, sLen - 1)
        SetDefaultPrinter ("DO NOT DELETE")
        SetDefaultPrinter (sDefPrinter)
        sDefPrinter = ""
    End If

End Function

NOTE: It is important to give the server enough time to redirect before running the code. If you don't, then only the printers that successfully redirected will be available. Depending on the number of printers to redirect (and if the drivers are using Easy Print drivers) the process can take from 5-30 seconds.

Thanks to everyone who attempted to answer the questions. We have been having this issues for years now, and we couldn't figure out why. I hope that MS decides to make the necessary changes to their Printer Collection.

LVL 58
ID: 40309810
Very nice!  Make sure you accept your own comment as answer.


Author Closing Comment

ID: 40320654
This was the best and only solution available for this problem.

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

627 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