Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140

    Unanswered: Open the print dialog box from a macro

    Is there a way to open the Print Dialog Box from within a macro?
    I've made my own shortcut menus ('right click menu") for reports by using the Access macros.

    I see the "PrintOut", but, printout uses the last printer used by that account, that can be problematic for us as we have to use Citrix for our remote users to log into the dbase.

    Basically what happens is this: Joe prints a report from computerA and logs out. Then he later tries to print another report from computerB it all blows up as Access is looking for ComputerA's printer to print out Joe's report.

    Is there a different way of making the shortcut menus without using the Macro? (Set something up in VBA perhaps?) I really don't care how much work I need to put into adding code/whatever into making this work as this *has* to work properly every time or there's no point in implementing my db when the time comes.

    Sam, it'll prolly be something right in front of my face again
    Good, fast, cheap...Pick 2.

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    Well, you can teach your users to use ctrl+p instead of printout

    Else, this is one of the advantages of a split FE/BE setup is that all the settings are remembered for the box it's on, unique to each box.
    Me.Geek = True

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    You shouldn't need the print dialog box, but I would advise similar to Nick -- teach users about CTRL-P. A little knowledge can save a LOT of frustrating coding.

    You could also customise the toolbars (provided it's NOT 2007) to give your users a "print" command that basically is the File - Print command, giving your user the print dialog when clicked.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140
    Mornin'

    Yeah, it's going to be a split db, but, one of the quirks of the Citrix network handler is that it remembers the last printer used for that account, it seems to bypass the Access/Windows default printer grab. That's why I almost have to force them to go through the print dialog box. As far as teaching them to use Ctrl + P, well we've got users all over the country...I can't spend that much time handling the same trouble calls after users forget or new users are added.

    Due to the nature of the beast this is going to be a very restrictive interface...they can do what they need to do, but, there'll be no menubars, and the right click will only be enabled on reports...which will only give them the Print command.

    I've done some more digging and figured out how to created a shortcut/popup menu using VBA, but, there's no RightClick() event for reports (argh!)...so I'm not sure where I can throw the code/call within the report to call the custom shortcut menu.

    Thanks for the input guys,

    Sam, I'll either figure this out or my head will explode
    Good, fast, cheap...Pick 2.

  5. #5
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140
    Got it!
    To help those who may ever need the same solution here it is step by step (and also in case I make a coding error someone may be able to catch it for me<g>)

    Create a new Module:

    Code:
    Public Function Print_Rpts
    
       Prnt_Reports
    
    End Function
    
    Private Sub Prnt_Reports
    
    on Error GoTo ErrHand
    
       DoCmd.R.U.nCommand acCmdPrint (drop the periods in run)
    
    ErrHand:
       
       If err = 2501 then 'catches the run time error if someone cancels from the print box
           Resume Next 
       End If
    
    End Sub
    Create a new macro,
    First row:
    Macro Name: &Print
    Action: Run Code
    In the Properties of the Run Code is a text box, enter the *Function Name* from the module: Print_Rpts() (*Must* include the () after the name or it will error out)

    Save the macro. (i.e. Rpt_Menu_Cmds)

    Create another new macro.
    Action: AddMenu

    In the properties of the AddMenu the name of your previous macro should appear in the dropdown list

    Save this Macro (i.e. mcr_Rpt_Menu)

    Then go through your reports and in the Property report under All>Shortcut Menu Bar type in the name of the second macro created (mcr_Rpt_Menu).

    Open the report, right click and your only option will be Print, and when you click it, will open the Printer Dialog Box.

    Sam, really not hard to do, just hard to find the correct information out there to do it.

    ::Edit::
    fixing a whoops
    Last edited by SCrandall; 09-18-09 at 12:47.
    Good, fast, cheap...Pick 2.

  6. #6
    Join Date
    May 2005
    Posts
    1,191
    Uuuugggh, macros *shiver*

    If you can't rely on training your users to do better, I'd still suggest sticking with ST's suggestion of just creating a custom toolbar with nothing but a print button that will pull up the print dialog box; you can even make the toolbar disappear and reappear on report activate and deactivate, respectively, thus making it only appear when the user is looking at this report. And you can even reuse this toolbar over and over for any other reports where you need to do similarly. Yay, everyone's happy!

    Cheers!
    Me.Geek = True

  7. #7
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140
    Except for when it gets worse and pretty much everything is popup/Modal to keep people from having too many forms/reports/whatnot open at once. No toolbars show (at least not that I've been able to find) when it's a maximized popup/modal form/report...covers the whole screen, including the task bar.
    I'm not thrilled about building macros, but, it it gets the job done and done right (IE Making the client happy) then that's what I'll have to do.

    If you know of a way to attach a toolbar to the print preview window of a report (and be able to attach it while creating a dynamic report on the fly) I'd be very interested in learning how.

    Thanks again,

    Sam
    Good, fast, cheap...Pick 2.

  8. #8
    Join Date
    May 2005
    Posts
    1,191
    Like I said, you can create a custom toolbar, and then show it when the report is activated (i.e. when it has the user's ""attention"), and then hide it when it is deactivated. On each of those report events, do something like:

    Code:
    CommandBars("cbarName").Visible = True
    And False on deactivate. I use this technique quite a bit actually and it works great for me. Cheers!
    Me.Geek = True

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I can't recall where I got this from but I found this in my archives.
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  10. #10
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140
    Afternoon,

    Thanks for the replies, sorry it's taken this long to respond...for some reason our servers and client machines *all* decided that everyone's passwords have expired even tho they're set to never expire...so I've had to deal with that issue first. (Must be another one of Microsoft's "Undocumented Features"...yay me!)

    Thanks for the input, I'll take a look at the solutions offered sometime this weekend and go from there.
    After that's done I get to design a message system for this thing, so I'm sure I'll be hounding y'all for help as I get mired in that.

    Thanks again,

    Sam
    Good, fast, cheap...Pick 2.

  11. #11
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Quote Originally Posted by SCrandall
    Afternoon,

    Thanks for the replies, sorry it's taken this long to respond...for some reason our servers and client machines *all* decided that everyone's passwords have expired even tho they're set to never expire...so I've had to deal with that issue first. (Must be another one of Microsoft's "Undocumented Features"...yay me!)

    Thanks for the input, I'll take a look at the solutions offered sometime this weekend and go from there.
    After that's done I get to design a message system for this thing, so I'm sure I'll be hounding y'all for help as I get mired in that.

    Thanks again,

    Sam
    If you're using MS Active Directory, I designed my own little mdb application which "tapped" into active directory and I could change the settings directly. It's in the code bank if you're interested but the code is messy and would need to be modified for your AD.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  12. #12
    Join Date
    Aug 2009
    Location
    Up Nort' Wi
    Posts
    140
    Sweet! I will look for it...could be very handy.

    Thanks,

    Sam
    Good, fast, cheap...Pick 2.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •