Activate the current window

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Probleminfinity
    New Member
    • Dec 2006
    • 7

    #1

    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.
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by Probleminfinity
    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

    [CODE=vb]option explicit
    dim boo1 as boolean
    sub importing()
    dim i as integer
    boo1=false
    i=1
    do
    if i > 50000 then exit do
    if boo1=true then exit sub 'the command will change the boolean
    cells(i,1).valu e = "hello world"
    i=i+1
    doevents 'This is the important thing here
    loop
    end sub

    '---------------Here is the code for the command button---------
    sub commandbutton1_ click()
    boo1=true
    end sub[/CODE]

    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

    Comment

    Working...