Connecting Tech Pros Worldwide Help | Site Map

Screen Refresh

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 01:54 AM
Kirk
Guest
 
Posts: n/a
Default Screen Refresh

I am doing a import of a file in to access. I have a form that is
updated for every record and every file that is imported. I would
like to be able to start and stop the process. However when I start
the process I am unable to stop it. All controls to the form are
lost. I think when I make the call to do the import module the
function will not continue till the module it called has finished
running. Is there a way to tell it to run this function but dont wait
for it to finish?
Thanks for you help,
Kirk

  #2  
Old November 13th, 2005, 01:54 AM
MGFoster
Guest
 
Posts: n/a
Default Re: Screen Refresh

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

There is only one thread running during VBA execution. So,...

In the called function use he DoEvents command. It will temporarily
stop the running code & allow other objects to raise an event.

It sounds like your called function is looping so try something like
this:

Set up a global variable in a standard module:

Public blnStopFunction As Boolean
==================

In the called function's loop do something like this:

Do While Not Eof(#inputFile)
..... file handling stuff
DoEvents
' Did user click the stop button
If blnStopFunction = True Then Exit Do
Loop

If blnStopFunction Then ... clean up open file then exit function

===============

On the form that calls the function, have a button, "Cancel," that sets
the blnStopFunction variable = True. When the DoEvents runs in the
called function loop, the click on the Cancel button will set the
blnStopFunction. The blnStopFunction check in the loop will determine
if the Cancel button has been clicked & if the routine should continue.
Be sure to clean up the file handling before returning to the calling
code (close the file, etc.).

Have some code in the calling code that will also check to see if the
called function completed or was cancelled - just check blnStopFunction
to see if it is True. Be sure to re-set to False afterward (so you can
call the function again w/o premature cancellation. Better yet, set the
variable to False before the initial call to the file handling function.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQSaKfIechKqOuFEgEQKChQCgy7g+Gcaeh7mFWMfFwOViQC uOiKQAoK2g
1EtLg77asvHnOFOph0u+YxRx
=0OcL
-----END PGP SIGNATURE-----


Kirk wrote:
[color=blue]
> I am doing a import of a file in to access. I have a form that is
> updated for every record and every file that is imported. I would
> like to be able to start and stop the process. However when I start
> the process I am unable to stop it. All controls to the form are
> lost. I think when I make the call to do the import module the
> function will not continue till the module it called has finished
> running. Is there a way to tell it to run this function but dont wait
> for it to finish?[/color]

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.