timer code

soulpiercing

Registered User.
Local time
Today, 15:34
Joined
Jan 5, 2003
Messages
27
I am sure there is an easy way to do it - but anyway...

does anyone have a sample of code to set the display time for a form then automatically close it? I want to use it for a splash screen form I am using.

Otherwise - anyone got a good sample of a splash screen?

Thanks
 
TIMER

Hi there Jason,

You would need to set the Timer Interval to say 1000 (Which is 1 sec) and on the ON Timer event write some code to do the following:

First dim a variable in the general section and initialize it
Second on the timer event increment its value and then check to see if it is a certain value - if yes then close the form and open another.

the code should look something like this:

Private Sub Form_Timer()
if secs => 5 then 'Secs is the variable set in the general
'section
timer1.enabled = false
unload me
else
secs = secs + 1
end if
End Sub

Happy programming,

Bert.
 
Re: TIMER

Bert666 said:
First dim a variable in the general section and initialize it

You don't need to declare the variable in the general section as you can declare a variable as Static which means it will remember its value from the last time the subroutine it is in was called.


Code:
Private Sub Form_Timer()

   Static intCount As Integer ' will remember its value from previous calling

   intCount = intCount + 1 ' increment the counter

   If intCount = 6 Then ' five seconds have passed
      With DoCmd      
         .Close acForm, Me.Name ' close the splash screen
         .OpenForm "YourForm", acNormal ' open your next form
      End With
   End If

End Sub
 
Try these in your Splash form's OnOpen and Timer events...

Private Sub Form_Open(Cancel As Integer)
Me.TimerInterval = 5000 'five seconds
End Sub

Private Sub Form_Timer()
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "YourFormNameHere", acNormal
End Sub

Also, here is a link to a sample I have recenlty posted that will help you with your problem...

Splash Screen

Searching this forum using the Keyword "splash" [without the quotes] will find tons of links to the subject with lots of examples and samples previous posters have provided.

HTH
 

Users who are viewing this thread

Back
Top Bottom