Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 29th, 2007, 11:34 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Activate the current window

Hi,

I have written some macro in VBA. It has 2 buttons one is SUBMIT and another is CANCEL. When i click on SUBMIT then it calls access and populate the data in another excel file and takes around 20-30 minutes to populate/complete the process. What I want is on click on CANCEL it should stop the process.

Any help will be appreciated.
 
Old August 29th, 2007, 04:44 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Insert DoEvents in your loop. There are several ways to acutally accomplish this.
This is quick and dirty. Create 2 buttons and name them (Start_Button and Stop_Button).

Put this code in the click routines:
----------------------------------------------------------------------
Private Sub Start_Button_Click()

'Starts code
  Do While "" = ""
    Cells(1, 1).Value = "Started"
    DoEvents
  Loop

End Sub

Private Sub Stop_Button_Click()

'Stops code
  Cells(1, 1).Value = "Not Started"
  End

End Sub
----------------------------------------------------------------------

A clean halt should have your code stopping after processing the record it's on or you may not like the results. One way to do this is to set a value that the running routine can check. Then when the running code checks this value it would know to stop after finishing current record.






Similar Threads
Thread Thread Starter Forum Replies Last Post
activate sheet mike0123m Excel VBA 1 August 11th, 2007 01:19 PM
multipage activate Fat_and_immoral Excel VBA 5 March 7th, 2007 02:03 PM
Form Activate help mohiddin52 Access VBA 2 January 5th, 2007 12:35 PM
close the current window kanoorani Javascript How-To 1 September 4th, 2005 09:58 PM
I want button action to change current window drb2k2 JSP Basics 0 June 4th, 2003 06:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.