On click event and display caption does not work

B

Boon

Hi,

Private Sub Command_import_Click()

Me.Label_Import.Caption = "Importing"


ImportWestCoast1

Me.Label_Import.Caption = ""

End Sub



Above is my code. What I want to do is when a user clicks a button, a label
in a form will display "Importing". When the process is done, the word
"Importing" disappears. It didn't work. When I click the button, I didn't
see the word Importing. The ImportWestCoast1 is a Procedure in my module. It
runs about 10 seconds.

Thanks for your help.

Boon
 
D

Dirk Goldgar

Boon said:
Hi,

Private Sub Command_import_Click()

Me.Label_Import.Caption = "Importing"


ImportWestCoast1

Me.Label_Import.Caption = ""

End Sub



Above is my code. What I want to do is when a user clicks a button, a
label in a form will display "Importing". When the process is done, the
word "Importing" disappears. It didn't work. When I click the button, I
didn't see the word Importing. The ImportWestCoast1 is a Procedure in my
module. It runs about 10 seconds.


It's likely that Access needs to be explicitly given a chance to update the
screen before your procedure runs. You can use the DoEvents statement for
this:

Me.Label_Import.Caption = "Importing"
DoEvents
ImportWestCoast1
Me.Label_Import.Caption = ""

It's possibly you need to add a Me.Repaint statement in there, too, but I'm
guessing that DoEvents will be enough.
 
K

Klatuu

Try this:

Private Sub Command_import_Click()

Me.Label_Import.Caption = "Importing"
Me.Repaint

ImportWestCoast1

Me.Label_Import.Caption = ""

End Sub

But, I would write it like this with the label defined in design mode:

Private Sub Command_import_Click()

With Me
.Label_Import.Visible = True
.Repaint
End With

ImportWestCoast1

Me.Label_Import.Visible = False

End Sub
 

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