Solved

MsgBox is printing when I press OK or Cancel.

Posted on 2004-03-27
5
368 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

948 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