On click event and display caption does not work

  • Thread starter Thread starter Boon
  • Start date Start date
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
 
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.
 
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
 
Back
Top