More than 1 timer?

M

Maarkr

I first used the timer interval to close the splash form and open the main
switch. I then renamed that sub and used the timer interval for a new sub
that scrolls text along the bottom. I thought i'd try to get the form to use
both the interval for the text scrolling (200) and the form closing (5000),
but that didn't work... while playing around with different ideas, I go to a
point where the form was not even visible, even tho I could look at the
properties; tried deleting the interval from the properties but it wouldn't
let me. Deleted all code for the form, but it still would not show the
form...I was glad I had a backup copy, so I deleted it and imported the
backup... anyway, can anyone think of how to code a sub to run both a
scrolling text object and then trigger a form closing sub ?
 
D

Douglas J. Steele

Try setting the form's TimerInterval to 200, and use code like:

Private Sub Form_Timer()
Static lngTimer As Long

' Put your code for the text scrolling here

lngTimer = lngTmer + 200

If lngTimer = 5000 Then

' Put your code for the form closing here

lngTimer = 0
End If

End Sub
 
M

Maarkr

Excellent! Here's the whole thing if someone wants it. I got the scrolling
marquee code from a link on this site but forgot who to credit... thanks

Private Sub Form_Timer()
On Error GoTo Err_Form_Timer

Static lngTimer As Long
Dim stDocName As String
Dim stLinkCriteria As String

lblMarquee.Caption = Mid(lblMarquee.Caption, 2) &
Left(lblMarquee.Caption, 1)
lngTimer = lngTimer + 200

If lngTimer = 5000 Then
DoCmd.Close

stDocName = "MainSwitch"
DoCmd.OpenForm stDocName, , , stLinkCriteria
lngTimer = 0
End If

Exit_Form_Timer:
Exit Sub

Err_Form_Timer:
MsgBox Err.Description
Resume Exit_Form_Timer
End Sub
 
D

Douglas J. Steele

Glad you got it working. Just be aware that some people loathe scrolling
text, and may chuck your application because of it!
 
R

riccifs

Glad you got it working. Just be aware that some people loathe scrolling
text, and may chuck your application because of it!

Hi Doug & Maarkr,
Is there a way to make scroll the text box's content and not just its
label?
How can I insert at least a couple of spaces, or something like that,
between the end of the scrolled text and its new restart?

Many Thanks,
Stefano.
 
B

Bob Quintal

(e-mail address removed) wrote in
Hi Doug & Maarkr,
Is there a way to make scroll the text box's content and not just
its label?
How can I insert at least a couple of spaces, or something like
that, between the end of the scrolled text and its new restart?

Many Thanks,
Stefano.
Because of the events which occur when a textbox is changed, it's
not practical. Besides, you cannot edit very well when the text is
scrolling.

You could hide the textbox, and put its contents into an unbound
label at form start or on current then scroll that.

me.label99.caption = me.textbox.value

To answer your second question, you could simply add 10 spaces in
front of the value when you set the caption

me.label99.caption = string(10," ") & me.textbox.value
 
R

rquintal

Hi Doug & Maarkr,
Is there a way to make scroll the text box's content and not just its
label?
How can I insert at least a couple of spaces, or something like that,
between the end of the scrolled text and its new restart?

Many Thanks,
Stefano.
Because of the events which occur when a textbox is changed, it's
not practical. Besides, you cannot edit very well when the text is
scrolling.

You could hide the textbox, and put its contents into an unbound
label at form start or on current then scroll that.

me.label99.caption = me.textbox.value

To answer your second question, you could simply add 10 spaces in
front of the value when you set the caption

me.label99.caption = string(10," ") & me.textbox.value
 
R

riccifs

Because of the events which occur when a textbox is changed, it's
not practical. Besides, you cannot edit very well when the text is
scrolling.

You could hide the textbox, and put its contents into an unbound
label at form start or on current then scroll that.

me.label99.caption = me.textbox.value

To answer your second question, you could simply add 10 spaces in
front of the value when you set the caption

me.label99.caption = string(10," ") & me.textbox.value

Many thanks for your hints, I have just one more question to ask for.
Is it possible for you to have control over the speed of scrolling
text or maybe halt the scrolling if the user passes the mouse over the
control!?
I think it will be great to integrate in the above code a
functionality like that but I'm not sure if is it possible to do that.
Could you help me in that?

I will really appreciate any kind of help.
Bye,
Stefano.
 
B

Bob Quintal

(e-mail address removed) wrote in
Many thanks for your hints, I have just one more question to ask
for. Is it possible for you to have control over the speed of
scrolling text or maybe halt the scrolling if the user passes the
mouse over the control!?
I think it will be great to integrate in the above code a
functionality like that but I'm not sure if is it possible to do
that. Could you help me in that?

I will really appreciate any kind of help.
Bye,
Stefano.
The TimerInterval property controls the speed at which the text
scrolls, a larger number slows it down. In the code, you would also
need to adjust the values in the two lines below to match.

lngTimer = lngTimer + 200
If lngTimer = 5000 Then

You could use the mouseover event of the label and the form to set a
flag dim'ed at the module level to true or false respectively and
put an IF block around the line that manipulates the
labelMarquee.caption so that it does not scroll, but letting the
other portions of the code continue.
 
R

rquintal

Many thanks for your hints, I have just one more question to ask for.
Is it possible for you to have control over the speed of scrolling
text or maybe halt the scrolling if the user passes the mouse over the
control!?
I think it will be great to integrate in the above code a
functionality like that but I'm not sure if is it possible to do that.
Could you help me in that?

I will really appreciate any kind of help.
Bye,
Stefano.

The TimerInterval property controls the speed at which the text
scrolls, a larger number slows it down. In the code, you would also
need to adjust the values in the two lines below to match.

lngTimer = lngTimer + 200
If lngTimer = 5000 Then

You could use the mouseover event of the label and the form to set a
flag dim'ed at the module level to true or false respectively and put
an IF block around the line that manipulates the labelMarquee.caption
so that it does not scroll, but letting the other portions of the code
continue.
 
R

riccifs

The TimerInterval property controls the speed at which the text
scrolls, a larger number slows it down. In the code, you would also
need to adjust the values in the two lines below to match.

lngTimer = lngTimer + 200
If lngTimer = 5000 Then

You could use the mouseover event of the label and the form to set a
flag dim'ed at the module level to true or false respectively and put
an IF block around the line that manipulates the labelMarquee.caption
so that it does not scroll, but letting the other portions of the code
continue.

I think I can understand that, but I'm not feel so confident to write
such type of code and I need more help to do you told me!
Could you give write it for me?

I'll really appreciate your effort.
Bye,
Stefano.
 
R

rquintal

On 20 Ott, 15:00, "(e-mail address removed)" <[email protected]>
wrote:



I think I can understand that, but I'm not feel so confident to write
such type of code and I need more help to do you told me!
Could you give write it for me?

I'll really appreciate your effort.
Bye,
Stefano.

Option Compare Database
Option Explicit

Dim bPause As Boolean

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
bPause = False
End Sub

Private Sub Form_Timer()
On Error GoTo Err_Form_Timer

Static lngTimer As Long
Dim stDocName As String
Dim stLinkCriteria As String

If Not bPause Then
lblMarquee.Caption = Mid(lblMarquee.Caption, 2) &
Left(lblMarquee.Caption, 1)
End If

lngTimer = lngTimer + Me.TimerInterval

If lngTimer >= 5000 Then
DoCmd.Close

stDocName = "MainSwitch"
DoCmd.OpenForm stDocName, , , stLinkCriteria
lngTimer = 0
End If

Exit_Form_Timer:
Exit Sub

Err_Form_Timer:
MsgBox Err.Description
Resume Exit_Form_Timer
End Sub

Private Sub lblMarquee_MouseMove(Button As Integer, Shift As Integer,
X As Single, Y As Single)
bPause = True
End Sub
 
R

riccifs

Option Compare Database
Option Explicit

Dim bPause As Boolean

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
bPause = False
End Sub

Private Sub Form_Timer()
On Error GoTo Err_Form_Timer

Static lngTimer As Long
Dim stDocName As String
Dim stLinkCriteria As String

If Not bPause Then
lblMarquee.Caption = Mid(lblMarquee.Caption, 2) &
Left(lblMarquee.Caption, 1)
End If

lngTimer = lngTimer + Me.TimerInterval

If lngTimer >= 5000 Then
DoCmd.Close

stDocName = "MainSwitch"
DoCmd.OpenForm stDocName, , , stLinkCriteria
lngTimer = 0
End If

Exit_Form_Timer:
Exit Sub

Err_Form_Timer:
MsgBox Err.Description
Resume Exit_Form_Timer
End Sub

Private Sub lblMarquee_MouseMove(Button As Integer, Shift As Integer,
X As Single, Y As Single)
bPause = True
End Sub

Hi,
I don't know where I'm making mistake but it doesn't work for me.
Could you check again the code... sorry about that!
 
R

riccifs

Hi,
I don't know where I'm making mistake but it doesn't work for me.
Could you check again the code... sorry about that!

OK! OK!,
I tried better and now it is working great!
Sorry for my previous post!

Many many thanks for your help!
Bye,
Stefano.
 
M

Maarkr

I know... I just was curious how to do a muti-timer event in case I need it
for other things. It is on an opening splash form (open for the 5 secs) that
I use on unfinished dbs that says something like 'This is an unfinished
version...blah, blah'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top