Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display "Loading" In Label While Loading DataEnvironment

Status
Not open for further replies.

CAPiTA

Technical User
May 27, 2005
16
US
I have a cbo on a form that loads a large dataenvironment. It takes 20-40 seconds to load the data, during which time I want a label on the form to display "Loading Data...". I've tried the following code, but the label goes blank when the data is loading. What did I do wrong?

Code:
Dim Str1 as String
Dim Str2 as String

Private Sub Form_Load()
   Str1 = "Ready"
   Str2 = "Loading Data..."
End Sub

Private Sub Combo1_Click()
If Combo1 = 001
   If Not Label1.Caption = Str2 Then
      Label1.Caption = Str2
   End If
   DataEnvironment1.Command1.Open
   If Not Label1.Caption = Str1 Then
      Label1.Caption = Str1
   End If
End If
End Sub
 
I recommend you add a DoEvents() after setting the label's caption.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
I tried the following and got the same result. Is the syntax right?

Code:
Dim Str1 as String
Dim Str2 as String

Private Sub Form_Load()
   Str1 = "Ready"
   Str2 = "Loading Data..."
End Sub

Private Sub Combo1_Click()
If Combo1 = 001
   If Not Label1.Caption = Str2 Then
      Label1.Caption = Str2
      DoEvents
   End If
   DataEnvironment1.Command1.Open
   If Not Label1.Caption = Str1 Then
      Label1.Caption = Str1
      DoEvents
   End If
End If
End Sub
 
I think the doevents should come after the open statement:

Private Sub Combo1_Click()
If Combo1 = 001
If Not Label1.Caption = Str2 Then
Label1.Caption = Str2
End If
DataEnvironment1.Command1.Open
doevents
If Not Label1.Caption = Str1 Then
Label1.Caption = Str1
End If
End If
End Sub

HTH



ciao for niao!

AMACycle

American Motorcyclist Association
 
The syntax looks ok.

Try something like this...
Code:
Private Sub Combo1_Click()
  If Combo1 = 001
    Label1.Caption = "Loading..."
    DoEvents
 
    DataEnvironment1.Command1.Open
   
    Label1.Caption = "Ready"
    [green]' You probably don't need this one.[/green]
    DoEvents
    
  End If
End Sub

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top