Running two routines at the same time

J

Jinjer

Hi.

Here's the situation:

1. I have a routine that refreshes the links to the backend tables
according to where the frontend is located.
2. I have an On Timer event in a form that flashes a label telling the user
that the data is being linked and to please stand by.

The problem is that they don't seem to be able to run at the same time. I
would like the label to blink WHILE the table linking is taking place, then
close when all is completed. However, when the RefreshLinks function runs,
the form's On Timer event doesn't. It's not much good if it runs after the
fact.

Any suggestions?
 
J

Jack Leach

I'm not sure how to make the timer and the relink run at the same time, but
as an alternative you might take a progress bar style approach and include
and update (flash) of your form's label through each loop iteration

ex

For Each tbl In TabelDefs
'run your link code
'then update your indicator
Next tbl


for that matter, maybe a progress bar itself would be a better approach as
this flashing will be inconsistent. If I remember correctly Stuart McCall
has a downloadable progress bar subform that you can iterate in such a
fashion. You can google "Stuart McCall Access" and look under his downloads
page... I don't remember the link offhand.

hth

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

David C. Holley

Scrap the timer.

Modify the code that updates the links to get the NUMBER of tables being
linked and insert a counter. Then in the code that loops through actually
relinking the tables update the label with the status. Something to the
effect of...

[label].caption = "Please wait - Checking Table " & i & " of " & tableCount
& " table(s)"
[label].repaint
i = i + 1

The .repaint ensures that the user sees the update to the caption.
 
J

Jinjer

Hi, Jack.

Thanks for the tip about Stuart McCall. I was able to look at his stuff and
realized I could get both sets of code to work by changing how they were
called. Instead of the form calling the routine to refresh the table links,
I have the routine opening the form at the start and closing it at the end:

Function RefreshLinks() As Boolean
DoCmd.OpenForm "frmLinkTables_Standby"
<RefreshLinks code>
DoCmd.Close acForm, "frmLinkTables_Standby"
End Function

The function can then be called by the Autoexec macro. Works perfectly.

Thanks again.
 
J

Jinjer

Hi, David.

Thanks for the suggestion. I used a modified form of it. I have changed my
code to:

Function RefreshLinks() As Boolean
Dim <other variables>
Dim sCap as string

DoCmd.OpenForm "frmLinkTables_Standby"
sCap = "The data link is being established. Please stand by."
<RefreshLinks code>
For Each tdf In dbs.TableDefs
Forms!f0LinkTables_Standby.lblStandBy.Caption = sCap
sCap = sCap & "."
<RefreshLinks code continues>
End Function

It just keeps adding another period with each loop, creating a progress meter.

Thanks again.
--
Jinjer


David C. Holley said:
Scrap the timer.

Modify the code that updates the links to get the NUMBER of tables being
linked and insert a counter. Then in the code that loops through actually
relinking the tables update the label with the status. Something to the
effect of...

[label].caption = "Please wait - Checking Table " & i & " of " & tableCount
& " table(s)"
[label].repaint
i = i + 1

The .repaint ensures that the user sees the update to the caption.

Jinjer said:
Hi.

Here's the situation:

1. I have a routine that refreshes the links to the backend tables
according to where the frontend is located.
2. I have an On Timer event in a form that flashes a label telling the
user
that the data is being linked and to please stand by.

The problem is that they don't seem to be able to run at the same time. I
would like the label to blink WHILE the table linking is taking place,
then
close when all is completed. However, when the RefreshLinks function
runs,
the form's On Timer event doesn't. It's not much good if it runs after
the
fact.

Any suggestions?


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top