Solved

CommonDialog Cancel Button

Posted on 1998-10-14
2
374 Views
Last Modified: 2008-03-06
OK, I'm sure its easy but I'm having trouble being able to tell if the user has pressed the Cancel button in the Printer Commondialog box.
Thanks,
Mike
0
Comment
Question by:qdsinc
2 Comments
 
LVL 4

Accepted Solution

by:
mcix earned 50 total points
ID: 1439964
Try this code:

Private Sub cmdPrint_Click()
   
    On Error GoTo err_cmdPrint_Click
    cdlgPrint.CancelError = True
    cdlgPrint.ShowPrinter
   
exit_cmdPrint_Click:
    Exit Sub
err_cmdPrint_Click:
   
        Select Case Err.Number
       
            Case cdlCancel
                MsgBox "User Cancelled"
                Resume exit_cmdPrint_Click
            Case Else
                MsgBox Err.Number & " - " & Err.Description, vbInformation, "An unexpected error"
                Resume exit_cmdPrint_Click
        End Select
Exit Sub

0
 

Author Comment

by:qdsinc
ID: 1439965
It worked, thanks alot.

Mike
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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 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

20 Experts available now in Live!

Get 1:1 Help Now