473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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.
Aug 29 '07 #1
1 1425
kadghar
1,295 Expert 1GB
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.
Hi, if you're using DO of FOR in your code that will make a DoEvents work that.
imagine you have your sub called Importing and commandbutton1 will stop it

Expand|Select|Wrap|Line Numbers
  1. option explicit
  2. dim boo1 as boolean
  3. sub importing()
  4. dim i as integer
  5. boo1=false
  6. i=1
  7. do
  8.     if i > 50000 then exit do
  9.     if boo1=true then exit sub   'the command will change the boolean
  10.     cells(i,1).value = "hello world"
  11.     i=i+1
  12.     doevents 'This is the important thing here
  13. loop
  14. end sub
  15.  
  16. '---------------Here is the code for the command button---------
  17. sub commandbutton1_click()
  18. boo1=true
  19. end sub
well that's the main idea
and sorry if im curious, have you tried importing your Access data into an array and asigning the array into a range, that should be quite fast.

Good Luck
Aug 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Milon | last post by:
Hi all, I am new to Python, and I just wrote a simple script to launch an application from the windows's start menu's run command. (see code as follow) There is an "OK" button on the new...
3
by: Michael Wu | last post by:
I wonder if anyone know how to activate a window with a given window handler. I used to do this with the win32 API static native boolean SetForegroundWindow(int hwnd); I wonder if there is...
4
by: bughunter | last post by:
In version 7.x connect to db activate db db SQL1494W Activate database is successful, however, there is already a connection to the database. works fine - db activated. In 8.x - No!...
9
by: MLH | last post by:
Say I open a form (MyForm) in design view, then I close it and dbl-click it in the database window to open it. Shouldn't the Activate event occur in all such situations? What might the case(s) be...
10
by: zhou | last post by:
in Visual Basic ,I use Appactivate(AcadApp.caption);
2
by: Dave Booker | last post by:
I have a Windows form application that I generally run minimized. When a critical event occurs it instantiates another "Alert" form which I want to grab the user focus. In the Alert constructor...
1
by: pearturtle123 | last post by:
Hi, I am new to Python and I am using PAMIE to manipulate IE browser. Currently, I have IE window 1 launched, after I clicked on a link on window 1, a second IE window 2 isopened. Then, I want...
7
by: Pubs | last post by:
I am learning C sharp. I want to call a function (any simple function. E.g. : Never ending while loop or large For loop inside the function). I want to call this function from the main application...
6
by: Eng Teng | last post by:
How do I write a code to activate a popup menu when I right click in a label control? Regards, Tee
1
by: suvaline | last post by:
I dont know much about VBA, but maybe somebody can help me ;) I have this kind of SUB .. Sub kama2() Worksheets("kama").Activate Range("A51").Select Selection.Hyperlinks(1).Follow...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.