Solved

MsgBox is printing when I press OK or Cancel.

Posted on 2004-03-27
5
356 Views
Last Modified: 2008-02-26
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
0
Comment
Question by:rcleon
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 10693787
Hi,
use

result = msgbox(...)

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

-FA
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 10693793
   If result= vbOK Then  
        'printing report
    Else ' if user clicks on Cancel nothing will happen
        'canceling report
    End If


-FA
0
 
LVL 54

Accepted Solution

by:
nico5038 earned 500 total points
ID: 10693801
Try:

IF MsgBox (" Please load Avery labels No. 5160 in the printer. Then press OK ", vbApplicationModal + vbOKCancel + vbInformation, "Title Company Labels") = vbOK then
    ' => print command
end if

The messagebox command will "return" the value of the button pressed, best to use the vbOK / vbYes / etc. variables as they "read" easy and Microsoft has a history of changing the numeric value of such return values.

Nic;o)
0
 
LVL 54

Expert Comment

by:nico5038
ID: 10721904
How far are we on thisone Rafael ?

Nic;o)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

757 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

21 Experts available now in Live!

Get 1:1 Help Now