Getting a form to change on a timer

  • Thread starter Thread starter james
  • Start date Start date
J

james

Hi,
I have a Form Called frmDisplay and it contains a Subform called
sbfrmDisplay. This subform displays the results of a query QryDisplayOrder.

I wish to code the form so that the contents of sbfrmDisplay changes between
4 queries. The one mentioned above and another query QryDisplayInterest,
QryDisplayInterestOther & QryDisplayOrderOther. I wish the contents to change
every ten seconds.

Thanks for the help. regards
James
 
james said:
Hi,
I have a Form Called frmDisplay and it contains a Subform called
sbfrmDisplay. This subform displays the results of a query
QryDisplayOrder.

I wish to code the form so that the contents of sbfrmDisplay changes
between
4 queries. The one mentioned above and another query QryDisplayInterest,
QryDisplayInterestOther & QryDisplayOrderOther. I wish the contents to
change
every ten seconds.

Thanks for the help. regards
James


Here's an example ...

Private Sub Form_Activate()

Me.TimerInterval = 10000

End Sub

Private Sub Form_Timer()

Select Case Me.sfrTest.SourceObject
Case "table.college"
Me.sfrTest.SourceObject = "table.contact"
Case "table.contact"
Me.sfrTest.SourceObject = "table.group"
Case Else
Me.sfrTest.SourceObject = "table.college"
End Select

End Sub

In this example I've assigned tables directly to the SourceObject property.
This isn't something I'd generally do or recomend in a production
application, I'd use forms instead, I just didn't have suitable forms
available for testing the example.
 
Hi Brendan
Adapted to use query and it works a treat. Thanks
Using the following code:

_______________________________________________
Private Sub Form_Activate()
Me.TimerInterval = 5000

End Sub

Private Sub Form_Load()
Me.Child4.SourceObject = "Query.DisplayOrdersEURGBP"
Me.Label5.Caption = "EURGBP"
End Sub

Private Sub Form_Timer()

Select Case Me.Child4.SourceObject
Case "Query.DisplayOrdersEURGBP"
Me.Child4.SourceObject = "Query.DisplayOrdersEURUSD"
Me.Label5.Caption = "EURUSD"
Case "Query.DisplayOrdersEURUSD"
Me.Child4.SourceObject = "Query.DisplayOrdersGBPUSD"
Me.Label5.Caption = "GBPUSD"
Case "Query.DisplayOrdersGBPUSD"
Me.Child4.SourceObject = "Query.DisplayOrdersOther"
Me.Label5.Caption = "OTHER"
Case "Query.DisplayOrdersOther"
Me.Child4.SourceObject = "Query.DisplayOrdersEURGBP"
Me.Label5.Caption = "EURGBP"

End Select
End Sub
______________________________________________________


Is there a way to make it so that if a query has nil results/records that it
automatically skips to the next Case/Query?

Cheers
James
 
Is there a way to make it so that if a query has nil results/records that
it
automatically skips to the next Case/Query?

Private Sub Form_Timer()

Dim lngRetries As Long
Dim lngRecords As Long

Do
lngRetries = lngRetries + 1
Select Case Me.sfrTest.SourceObject
Case "table.college"
Me.sfrTest.SourceObject = "table.contact"
lngRecords = DCount("*", "contact")
Case "table.contact"
Me.sfrTest.SourceObject = "table.group"
lngRecords = DCount("*", "group")
Case Else
Me.sfrTest.SourceObject = "table.college"
lngRecords = DCount("*", "college")
End Select
If lngRecords > 0 Then
Exit Do
End If
Loop Until lngRetries > 2

End Sub

The purpose of the lngRetries variable is to prevent the code getting into
an endless loop if all three queries returned no records.
 
Back
Top