Link to home
Start Free TrialLog in
Avatar of rcleon
rcleonFlag for United States of America

asked on

MsgBox is printing when I press OK or Cancel.

Hi Guys,

What is wrong with this code.

MsgBox " Please load Avery labels No. 5160 in the printer. Then press OK ", vbApplicationModal + vbOKCancel + vbInformation, "Title Company Labels"

The idea is when the user press OK the report prints when the user press cancel the report should not print the msgbox disapears and the user is return to the application.

But right now the report prints when you press OK or Cancel or Close the MsgBox.

Please help.

Rafael
Avatar of Farzad Akbarnejad
Farzad Akbarnejad
Flag of Iran, Islamic Republic of image

Hi,
use

result = msgbox(...)

and check the result in a If-Then-End if statement

-FA
   If result= vbOK Then  
        'printing report
    Else ' if user clicks on Cancel nothing will happen
        'canceling report
    End If


-FA
ASKER CERTIFIED SOLUTION
Avatar of nico5038
nico5038
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How far are we on thisone Rafael ?

Nic;o)