Results 1 to 14 of 14
  1. #1
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115

    Set Warnings does not work

    Hello! Leon here! I have a button which, when pressed, prints out details of the person's record, identified by their ID code. It works perfectly, except it shows the printer dialogue box - which I do not want the user to see. The question is, how do I stop the dialogue box from appearing. I am using Warnings and Echo !!?? And I have made an adjustment in the Options facility. Thank you.



    Code:
     Private Sub PrintContactDetails_Click()On Error GoTo PrintContactDetails_Click_Err
    
    
        DoCmd.Echo False, ""
        DoCmd.SetWarnings False
        DoCmd.RunMacro "PrintReportNew", , ""
        DoCmd.SetWarnings True
        DoCmd.Echo True, ""
    
    
    PrintContactDetails_Click_Exit:
        Exit Sub
    
    
    PrintContactDetails_Click_Err:
        MsgBox Error$
        Resume PrintContactDetails_Click_Exit
    
    
    End Sub.....

  2. #2
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    I think you need to set the option to print the report directly.

    Because you are using a macro I can't tell what command you are using to print the report.
    And why use a macro for that bit when you are using code for the rest of it?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,754
    Best to just use a DoCmd RunMacro and set the warnings on / off in the Macro
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,861
    use acviewnormal in your docmd.openreport arguments.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    Warnings on/off won't stop the print dialogue showing up. It's not a warning.

    You need to use a method that simply prints directly to the printer.
    In VBA
    Code:
    DoCmd.OpenReport "rptYourReport", acViewNormal
    Would normally simply print the report directly to the default printer for that report
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  6. #6
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Thanks for that - Mike60Smart - but it does not work!! It works elsewhere but not in that macro. But i will try again, by re-writing the macro! Thanks.

  7. #7
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Moke123 - thanks for that. An interesting option - I will try. Thanks!

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,861
    Quote Originally Posted by LeonS View Post
    Moke123 - thanks for that. An interesting option - I will try. Thanks!
    It's not an option Leon, it's how you send a report direct to printer.
    See Mintys post #5.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  9. #9
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    My apologies for the wrong use of a word!! Please remember that I am but a small bush in a forest of tall trees!

  10. #10
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Moke123 - I have changed the code as follows:
    Code:
    DoCmd.Echo False, ""    DoCmd.SetWarnings False
        'DoCmd.RunMacro "PrintReportNew", , ""
        DoCmd.OpenReport "ContactR", acViewNormal
        DoCmd.SetWarnings True
        DoCmd.Echo True, ""
    And this is what happens on screen
    Click image for larger version. 

Name:	DialogueBoxShowing.png 
Views:	17 
Size:	38.3 KB 
ID:	46114

  11. #11
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    That isn't a print dialog - it's asking you for a parameter, presumably for the underlying query that the report is based on.
    You probably need to supply that or make sure the form it is referenced on is open.

    Remove all that set warnings and echo stuff, it's not achieving anything, other than possibly hiding some genuine error codes.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  12. #12
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Minty - I have removed all the Warnings and Echo stuff, as you suggested. There is still a message/ dialogue box opening and going away. This is apart from the message box that asks for the ID number.
    My methodology is that there is a Report. Which of the contacts details are printed on that report depends on their ID number. The query has an [Enter....] criteria in the ID field. Thus when you open the query, the message box asks for the ID number. So far so good. The code behind the "Print" button is below.
    But behind the Criteria request message box there is a "dialogue" box that appears. I cannot see the content but I believe it is just saying "The report is being printed". I would like for that other message/ dialogue box, not to appear. If you have another look at the screen print I sent you, you will see 2 boxes. The ID Request box (meant to be there) and, behind it, the other dialogue/ message. I hope this helps. It is the only print request button in the db, so I have nothing with which to compare.
    Could it be a print setting within the db or in the printer setup? The printer is the default printer connected to the PC. Leon

    Code:
    Private Sub PrintContactDetails_Click()On Error GoTo PrintContactDetails_Click_Err
    
    
        DoCmd.OpenReport "ContactR", acViewNormal
    
    
    PrintContactDetails_Click_Exit:
        Exit Sub
    
    
    PrintContactDetails_Click_Err:
        MsgBox Error$
        Resume PrintContactDetails_Click_Exit
    
    
    End Sub

  13. #13
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,861
    Thats the "Printing" dialog, not the "Print" dialog.

    see this article which states it cannot be hidden but can be minimized. I've never used it but give it a shot.

    http://access.mvps.org/access/api/api0037.htm
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  14. #14
    LeonS is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jul 2014
    Posts
    115
    Thanks for that. Amazing! First because you found it - deep research! and because of the knowledge Dev must have of Access. To be honest, there seems (to me!) to be too much that could go wrong. The next time I am in Lockdown, I may give it a try!!! I truly Thank You for your efforts. Leon

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Turn off warnings?
    By DevState in forum Programming
    Replies: 1
    Last Post: 08-01-2018, 01:39 PM
  2. set warnings autoexec
    By bchi99 in forum Queries
    Replies: 6
    Last Post: 11-14-2014, 02:20 PM
  3. Errors but not warnings ?
    By asearle in forum Access
    Replies: 3
    Last Post: 08-10-2011, 01:26 AM
  4. Turn warnings off
    By Mclaren in forum Programming
    Replies: 6
    Last Post: 05-03-2010, 12:07 PM
  5. Set Warnings Off
    By NMJones in forum Access
    Replies: 2
    Last Post: 04-12-2010, 03:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums