none
VFP 9.0 Printer Setup in app created gives error 1957 RRS feed

  • Question

  • I've created an app that every time I try to use the Printer Setup from File I get an error after selecting anohter printer, "Error 1957,0  Error accessing printer spooler" but it will print to the new printer selected.

    Also I can not use the Getprinter() function in any of my forms or I get the same error message and it does not print to the printer selected.

    Tuesday, March 23, 2010 7:20 PM

Answers

  • There is a bug in VPF9 after discussing it with a Microsoft help person and them investigating it. Can't believe it was not caught till now. I kept thinking I was doing something wrong especially since it is the same code used in VFP6. It only happens when you use the Wizard to create a new project. He said to replace the default menu command under File - Printer Setup with do fix_print.prg and of course include the fix_print.prg in your code tab in the project.

    fix_print.prg

    * Beginning of program

     

     

     

    LOCAL lcPrinter

    lcPrinter = ''

    lcPrinter =

     

    GETPRINTER()

     

     

    IF !EMPTY(lcPrinter)

     

     

    SET PRINTER TO NAME (lcPrinter)

     

     

    ENDIF

     

     

     

    *

    * End of program

    Tuesday, June 15, 2010 10:52 PM
  • OK my bad - it was late.

    My point is that if you know the name of the printer then you shouldn't have to use GETPRINTER()

    When using GETPRINTER() there is no problem. If you don't use GetPrinter() then there is a sporadic issue with both

    Set Printer to Name &PrntName

    and Set printer to Name (PrntrName)

    And this can be demonstrated VFP 9 and VFP 6.

    You can continue to use GetPrinter(). I will not because I know the name of the printer already secondly it involves user intervention.

     

    Tuesday, September 28, 2010 5:04 PM
  • Hi "ve6raj"
     
    Duh.. I only used the GETPRINTER() to populate a correct printername into the variable. Of course if you have already stored that information in a table-field then obviously it is not necessary to call that function again....
     
    But regardless of how you have that printer-name stored, you need to realize that it's the macro operator which will give you the "sporadic issue". Have a look at this two possible scenarios:
     
    cPrinter1 = "HPLaserjet"    && Just a sample name, substitute it with your real printer name
    cPrinter2 = "HP Laserjet"   && see the space inbetween
    SET PRINTER TO NAME &cPrinter1
     
    Since that codeline contains the macro operator, this line is stored as written in the EXE, and only at runtime the code gets expanded to now read as
    SET PRINTER TO NAME HPLaserjet 
    This will obviously work.
     
    But now see the result with the second printer name:
    SET PRINTER TO NAME HP Laserjet 
     
    This codeline will NOT work, because a) you have no printer called "HP" only, and b) VFP doesn't know what to do with that "Laserjet" commandline part.  That's why you should not use Macros for variables. This cannot happen with Indirect Referencing.
     
    The only other thing to watch for when using Indirect References and printer-names stored in a table-field: You need to RTRIM() the field content:
    SET PRINTER TO NAME (RTRIM(ConfigTable.PrinterName))
     
     

    wOOdy
    Microsoft Visual FoxPro Technology Advisor
    Microsoft "Most Valuable Professional" from 1996 to 2009
    Visit my XING profile! Don't know what XING is?

    *´¨)
    ¸.·´¸.·*´¨) ¸.·*¨)
    (¸.·´. (¸.·` *
    .·`.Visual FoxPro: It's magic !
    (¸.·``··*


     

    Thursday, September 30, 2010 3:07 PM

All replies

  • Some Time VFP can not Access Printer Driver due to Problem of Windows. 

    Try it in other PC. 

    If your app work in other PC fine then you have to reinstall Windows in Current PC.

     

     



    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh's Blog
    Wednesday, March 24, 2010 4:23 AM
    Answerer
  •    The same problem exists when the app is loaded on another machine also when I used VFP 6.0 there were no problems. It only occurred when I updated to VFP 9.0. I'll try loading VFP to another computer to see if that is the problem.
    Wednesday, March 24, 2010 6:05 PM
  • It looks like you printer driver is old. You may try to install the newest version of printer driver ....
    dni
    Wednesday, March 24, 2010 6:40 PM
  • If I choose to create a new project and use the wizard to build it. Then I compile the project into an EXE. Then I run the EXE and choose under File - printer setup and select a different printer I get error 1957 unable to access printer spooler settings. No problems if I use VFP 6.0. What's up with that.
    • Merged by Martin_Xie Wednesday, March 31, 2010 9:26 AM Merge them to keep in one same topic.
    Wednesday, March 24, 2010 10:31 PM
  • Yoy may try to update printer driver .
    dni
    Thursday, March 25, 2010 11:55 AM
  • It works fine in VFP 6.0. When I updated to VFP 9.0 it started. Also when I select from File then Printer Setup I receive the Page Setup Screen then I have to select Printer to display the printers available versus in VFP 6.0 I select the printer with no page setup popping up first. Is Page Setup supposed to pop up first in VFP 9.0?

     

    Thursday, March 25, 2010 7:25 PM
  • Don't think that is the issue. I updated the driver and still the same problems.

    When I start VFP 9.0 I can go to Printer Setup and select a printer with no error. Also in the printer setup I have the Page Setup screen first then I have to click on Printer to select. I did not do it that way in VFP 6.0. It went directly to the printer selection. Is that the new format?

    Thursday, March 25, 2010 7:29 PM
  • I get the same problem as you do and I am using windows xp. Also found this to be a problem in windows 7.
    Friday, April 23, 2010 8:48 PM
  • Hi,

    Same problem i faced. I Solved my Problem by Formatting Windows.

     

     



    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh's Blog
    Saturday, April 24, 2010 3:44 AM
    Answerer
  • Really, Kalpesh? I have found this problem on four different computers with three different O/S.. I doubt they all need to be reformatted.  I suspect this is a BUG in VFP 9 sp2, perhaps the genmenu.prg or something in the app builder class that generated the menu in the first place. Has anyone even tried to reproduce this error? I would hope there are more than two people on this planet they have the same problem which produces the same results using the same steps to reproduce it.
    Saturday, April 24, 2010 9:22 PM
  • Hi James

    My Client faced same problem many times. I did not find any solution. 

    So i can solved my problem by pc formatting.

     

     



    Please "Mark as Answer" if this post answered your question. :)

    Kalpesh Chhatrala | Software Developer | Rajkot | India

    Kalpesh's Blog
    Sunday, April 25, 2010 1:56 PM
    Answerer
  • VFP 9.0 Printer Setup in app created gives error 1957. I used the default builder and the menu generated. I get an error when I click on print setup in menu after clicking on the printer button and then click cancel. The error is "Error accessing printer spooler"

    Examine self-generated code behind the menu item:
    "SET PRINTER TO NAME (SYS(1037))"

    no wonder print spooler cannot find 1 or 0 for that is what sys(1037) returns....in VFP9, earlier version sys(1037) did not return a value.

    go figure..........

    Better to use getprinter() or just plain sys(1037)

    or even better...http://www.foxite.com/archives/0000219077.htm

    • Proposed as answer by James Frye Sunday, April 25, 2010 7:10 PM
    Sunday, April 25, 2010 7:09 PM
  • I found out there was a bug when you use the project wizard to create a new project. Microsoft is aware of it and will now share a fix for it.
    Saturday, June 12, 2010 2:43 AM
  • The problem lied in the wizzard. Microsoft was unaware of it.
    Saturday, June 12, 2010 2:45 AM
  • There is a bug in VPF9 after discussing it with a Microsoft help person and them investigating it. Can't believe it was not caught till now. I kept thinking I was doing something wrong especially since it is the same code used in VFP6. It only happens when you use the Wizard to create a new project. He said to replace the default menu command under File - Printer Setup with do fix_print.prg and of course include the fix_print.prg in your code tab in the project.

    fix_print.prg

    * Beginning of program

     

     

     

    LOCAL lcPrinter

    lcPrinter = ''

    lcPrinter =

     

    GETPRINTER()

     

     

    IF !EMPTY(lcPrinter)

     

     

    SET PRINTER TO NAME (lcPrinter)

     

     

    ENDIF

     

     

     

    *

    * End of program

    Tuesday, June 15, 2010 10:52 PM
  • There is a bug in VPF9 after discussing it with a Microsoft help person and them investigating it. Can't believe it was not caught till now. I kept thinking I was doing something wrong especially since it is the same code used in VFP6. It only happens when you use the Wizard to create a new project. He said to replace the default menu command under File - Printer Setup with do fix_print.prg and of course include the fix_print.prg in your code tab in the project.

    fix_print.prg

    * Beginning of program

     

     

     

    LOCAL lcPrinter

    lcPrinter = ''

    lcPrinter =

     

    GETPRINTER()

     

     

    IF !EMPTY(lcPrinter)

     

     

    SET PRINTER TO NAME (lcPrinter)

     

     

    ENDIF

     

     

     

    *

    * End of program

    Tuesday, June 15, 2010 10:53 PM
  • This really isn't a fix.  If you use the getprinter routine then there is never any problem. The problem is when you know the printer name and use

    Set printer to &&LabelPrntr

    The idea is if you know the printer name that you want to print to you should not have to use getprinter()

     

    This bug occasionally shows up in VFP6 under XP SP3 as well

     

    Monday, September 27, 2010 4:55 PM
  • Hi "ve6raj"
     
    This is not a bug, this is just a plain coding error on your side
     
    >> Set printer to &&LabelPrntr
     
    Besides of having one macro-operator too much, the real problem is that printer names can have spaces in them. The correct coding is to use parantheses instead of macros. Only use macros if you really need to insert real program code. If you need to substitute variables, field-names, window-names, etc then always use the "Indirect referencing":
     
    cPrintername = GETPRINTER()
    SET PRINTER TO NAME (cPrinterName)
     
    That way the spaces in the printername doesn't generate faulty code.
     
     

    wOOdy
    Microsoft Visual FoxPro Technology Advisor
    Microsoft "Most Valuable Professional" from 1996 to 2009
    Visit my XING profile! Don't know what XING is?

    *´¨)
    ¸.·´¸.·*´¨) ¸.·*¨)
    (¸.·´. (¸.·` *
    .·`.Visual FoxPro: It's magic !
    (¸.·``··*


     

    Tuesday, September 28, 2010 8:58 AM
  • OK my bad - it was late.

    My point is that if you know the name of the printer then you shouldn't have to use GETPRINTER()

    When using GETPRINTER() there is no problem. If you don't use GetPrinter() then there is a sporadic issue with both

    Set Printer to Name &PrntName

    and Set printer to Name (PrntrName)

    And this can be demonstrated VFP 9 and VFP 6.

    You can continue to use GetPrinter(). I will not because I know the name of the printer already secondly it involves user intervention.

     

    Tuesday, September 28, 2010 5:04 PM
  • Hi "ve6raj"
     
    Duh.. I only used the GETPRINTER() to populate a correct printername into the variable. Of course if you have already stored that information in a table-field then obviously it is not necessary to call that function again....
     
    But regardless of how you have that printer-name stored, you need to realize that it's the macro operator which will give you the "sporadic issue". Have a look at this two possible scenarios:
     
    cPrinter1 = "HPLaserjet"    && Just a sample name, substitute it with your real printer name
    cPrinter2 = "HP Laserjet"   && see the space inbetween
    SET PRINTER TO NAME &cPrinter1
     
    Since that codeline contains the macro operator, this line is stored as written in the EXE, and only at runtime the code gets expanded to now read as
    SET PRINTER TO NAME HPLaserjet 
    This will obviously work.
     
    But now see the result with the second printer name:
    SET PRINTER TO NAME HP Laserjet 
     
    This codeline will NOT work, because a) you have no printer called "HP" only, and b) VFP doesn't know what to do with that "Laserjet" commandline part.  That's why you should not use Macros for variables. This cannot happen with Indirect Referencing.
     
    The only other thing to watch for when using Indirect References and printer-names stored in a table-field: You need to RTRIM() the field content:
    SET PRINTER TO NAME (RTRIM(ConfigTable.PrinterName))
     
     

    wOOdy
    Microsoft Visual FoxPro Technology Advisor
    Microsoft "Most Valuable Professional" from 1996 to 2009
    Visit my XING profile! Don't know what XING is?

    *´¨)
    ¸.·´¸.·*´¨) ¸.·*¨)
    (¸.·´. (¸.·` *
    .·`.Visual FoxPro: It's magic !
    (¸.·``··*


     

    Thursday, September 30, 2010 3:07 PM
  • where the hell we have to type this program ?????????????

    error code :1957

    spool printer

    • Edited by RAM8939 Friday, June 20, 2014 1:57 PM
    Friday, June 20, 2014 1:53 PM
  • Hi RAM8939

    What the hell do you mean?  (just using your own wording)


    wOOdy
    Microsoft Visual FoxPro and Servoy Technology Advisor
    Microsoft "Most Valuable Professional" from 1996 to 2009
    Visit my XING profile, my LinkedIn profile, my Facebook page!

    *´¨)
    ¸.·´¸.·*´¨) ¸.·*¨)
    (¸.·´. (¸.·` *
    .·`.Visual FoxPro: It's magic !
    (¸.·``··*


     

    Friday, June 20, 2014 3:04 PM