Visible property not working

G

Guest

I'm trying to have a label appear right after the button is clicked then
disappear after the process is finished.

Here's the code:

********************
Private Sub btnCreateTable_Click()
On Error GoTo Err_btnCreateTable_Click

Dim stDocName, strSQL As String

' Display test so they know the process has started

Working.Visible = True

' Remove the data already in the table

strSQL = "DELETE ProductsUsedByWorkstation.* FROM
ProductsUsedByWorkstation;"

CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges

' Append the unique Asset names to the table based on the date range
specified
' If no dates specified, run for all data

strSQL = "INSERT INTO ProductsUsedByWorkstation ( AssetName ) SELECT
DISTINCT DailyDatawithProductandVersion.AssetName FROM
DailyDatawithProductandVersion "

If [BeginDate] > 0 Then

strSQL = strSQL & "WHERE (((DailyDatawithProductandVersion.RunDate)
Between #" & [BeginDate] & "# And #" & [EndDate] & "#));"

End If

CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges

' Hide "Working" text and display "Completed" text

Working.Visible = False
Completed.Visible = True

Exit_btnCreateTable_Click:
Exit Sub

Err_btnCreateTable_Click:
MsgBox Err.Description
Resume Exit_btnCreateTable_Click

End Sub

************************

The label 'Working' does not appear but the 'Completed' label does.

Help?
 
G

George Nicholson

Depending on how quickly your queries execute, its likely that the screen
simply never has a chance to update while the label is visible and your code
is running. You can try to force it.

Try either issuing a DoEvents or a refresh/repaint (Me.Refresh) command
after Working.Visible = True.

HTH,
 
D

Dirk Goldgar

In
George Nicholson said:
Depending on how quickly your queries execute, its likely that the
screen simply never has a chance to update while the label is visible
and your code is running. You can try to force it.

Try either issuing a DoEvents or a refresh/repaint (Me.Refresh)
command after Working.Visible = True.

Me.Refresh would probably be a bad idea, as it would force the saving of
a dirty record. Repaint might work, but I think your idea of using the
DoEvents statement is best.

Working.Visible = True
DoEvents

' ... do stuff ...

Working.Visible = False
DoEvents ' this one may not be necessary
 

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