Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cancel Button not Active on Form when in Print Clicked event 1

Status
Not open for further replies.

Alleyopp

Programmer
Sep 17, 2004
22
US
I need to be able to allow the user to cancel a print job.
The form allows the user to click a print button to print out multiple reports. Actually it gets the data from the DB and puts into the word form then prints it out.. It continues thru the recordset until all the Reports are printed.
I need to have the user be able to click on the Cancel button on the form but I can not seem to be able to make the button active.

When the user selects print (cmdPrint_Click)
I make the cancel print button visible.
but the button is not active on the form..
I have tried to set focus the button but it still does not allow the button to work.. I am assuming it is because I am in the cmdPrint_click event??

I don't want to use a msgbox because if the user is printing out 100 reports this forces the user to click OK to continue each time... They did not like that idea..

Here is my code:
CancelPrint is a global that is set to true in the cmdCancel_click event.
The Print_Quad_Chart_FY05 send the data to a word form to be printed out.
-------------------------------------------------------
Code:
cmdPrint_Click()
 Me.cmdCancel.Visible = True
 .
 .
 .
 Do While Not rst.EOF
        Me.cmdCancel.SetFocus
        If CancelPrint Then     
           okcan = MsgBox("Press Cancel to Stop Printing",  vbOKCancel)
            If okcan = vbCancel Then
               Exit Do
            End If
        End If
        Call Print_Quad_Chart_FY05(NZ(rst("Quad_id").value, 0), True, pfile, pout, copies)
     
        rst.MoveNext
    Loop
-----------------------------------------------------------
Me.cmdCancel.SetFocus Did NOT Work...
Any suggestions would help..

Yes, I tried to search but it was down..
Thanks
Alley
 
In your Do...Loop put a DoEvents command right before "If CancelPrint Then".

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Thanks much that does it..
I will have to do some reading on DoEvents.. It looks like it is very useful..


Thanks
Alley
 
New issue..
The DoEvent works great..
but you can not tell if the cancel button is clicked..
When a button is clicked the shadowing goes to the botton so it appears different and looks like it was depressed.
However when you click the button it does nothing.. so the user can not tell if they clicked it or not..

How do I make it look depressed or activate the button so it will do it automatically?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top