If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Getting a form to change on a timer
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 |
#2
|
|||
|
|||
Getting a form to change on a timer
"james" wrote in message
... 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. -- Brendan Reynolds |
#3
|
|||
|
|||
Getting a form to change on a timer
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 "Brendan Reynolds" wrote: "james" wrote in message ... 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. -- Brendan Reynolds |
#4
|
|||
|
|||
Getting a form to change on a timer
"james" wrote in message
... snip 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. -- Brendan Reynolds |
Thread Tools | |
Display Modes | |
|
|