A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Getting a form to change on a timer



 
 
Thread Tools Display Modes
  #1  
Old February 4th, 2010, 11:52 AM posted to microsoft.public.access.forms
JAmes
external usenet poster
 
Posts: 904
Default 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  
Old February 4th, 2010, 01:29 PM posted to microsoft.public.access.forms
Brendan Reynolds
external usenet poster
 
Posts: 1,241
Default 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  
Old February 4th, 2010, 04:47 PM posted to microsoft.public.access.forms
JAmes
external usenet poster
 
Posts: 904
Default 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  
Old February 5th, 2010, 02:00 PM posted to microsoft.public.access.forms
Brendan Reynolds
external usenet poster
 
Posts: 1,241
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.