updating labels

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 2 labels on my form that I want to update with the "current process"
and the time it started. The "current process" relates to the query the
macro is currently running.

Once I click the button to start the macro, only the "Running Query 3"
message is displayed. Once I click the "OK" button on the msgbox, then the
labels are cleared as expected. What I haven't been able to do is display
the "Running Query 1" and "Running Query 2" messages. Following is the code
I use:

Sub Clear_Tables()

Dim QueryName As String
Dim vCurrTime As Date

SysCmd acSysCmdClearStatus
Forms![Invoice]![Label1].Caption = ""
Forms![Invoice]![Label2].Caption = ""

vCurrTime = Time
Forms![Invoice]![Label1].Caption = "Running Query 1"
Forms![Invoice]![Label2].Caption = vCurrTime

QueryName = "Query 1"
DoCmd.OpenQuery QueryName

vCurrTime = Time
Forms![Invoice]![Label1].Caption = "Running Query 2"
Forms![Invoice]![Label2].Caption = vCurrTime

QueryName = "Query 2"
DoCmd.OpenQuery QueryName

vCurrTime = Time
Forms![Invoice]![Label1].Caption = "Running Query 3"
Forms![Invoice]![Label2].Caption = vCurrTime

QueryName = "Query 3"
DoCmd.OpenQuery QueryName

MsgString = "The data tables have been cleared. Import the data now."
MsgBox MsgString, , "Tables Cleared"

Forms![Invoice]![Label1].Caption = ""
Forms![Invoice]![Label2].Caption = ""

End Sub

Any suggestions on how I can get all of the messages to display would be
appreciated. I've tried using messages on the status bar but that isn't
working because the messages are being replaced by the progress bar when some
of the queries are running. I've also tried adding the "sleep" command at
various places but the results are the same........Thanks.....
 
Access does not bother updating the screen if there is more important work
to do, but you can force it with a Repaint.

Try:
Me.Repaint
after the queries.

It may depend where you call this from. (Some events don't permit screen
updates.)

BTW, if these are action queries, you might find it better to use RunSQL or
dbEngine(0)(0).Execute.
 
Thanks.......the repaint command did the trick.
--
JT


Allen Browne said:
Access does not bother updating the screen if there is more important work
to do, but you can force it with a Repaint.

Try:
Me.Repaint
after the queries.

It may depend where you call this from. (Some events don't permit screen
updates.)

BTW, if these are action queries, you might find it better to use RunSQL or
dbEngine(0)(0).Execute.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

JT said:
I have 2 labels on my form that I want to update with the "current process"
and the time it started. The "current process" relates to the query the
macro is currently running.

Once I click the button to start the macro, only the "Running Query 3"
message is displayed. Once I click the "OK" button on the msgbox, then
the
labels are cleared as expected. What I haven't been able to do is display
the "Running Query 1" and "Running Query 2" messages. Following is the
code
I use:

Sub Clear_Tables()

Dim QueryName As String
Dim vCurrTime As Date

SysCmd acSysCmdClearStatus
Forms![Invoice]![Label1].Caption = ""
Forms![Invoice]![Label2].Caption = ""

vCurrTime = Time
Forms![Invoice]![Label1].Caption = "Running Query 1"
Forms![Invoice]![Label2].Caption = vCurrTime

QueryName = "Query 1"
DoCmd.OpenQuery QueryName

vCurrTime = Time
Forms![Invoice]![Label1].Caption = "Running Query 2"
Forms![Invoice]![Label2].Caption = vCurrTime

QueryName = "Query 2"
DoCmd.OpenQuery QueryName

vCurrTime = Time
Forms![Invoice]![Label1].Caption = "Running Query 3"
Forms![Invoice]![Label2].Caption = vCurrTime

QueryName = "Query 3"
DoCmd.OpenQuery QueryName

MsgString = "The data tables have been cleared. Import the data now."
MsgBox MsgString, , "Tables Cleared"

Forms![Invoice]![Label1].Caption = ""
Forms![Invoice]![Label2].Caption = ""

End Sub

Any suggestions on how I can get all of the messages to display would be
appreciated. I've tried using messages on the status bar but that isn't
working because the messages are being replaced by the progress bar when
some
of the queries are running. I've also tried adding the "sleep" command at
various places but the results are the same........Thanks.....
 
Add Me.Repaint immediately after the statements setting the captions.
This will repaint the Form on which they exist.
 
Back
Top