Results 1 to 5 of 5
  1. #1
    Join Date
    May 2016
    Posts
    9
    Provided Answers: 1

    Answered: change textbox on a timer

    Hey everyone I have a problem that i can not find an answer to. So far i've found answers to every problem i've had on this site except this one and its probably easy.

    This is what i want to do. I want to change the text of a textbox on a timer. I would like the text to display for about 3 seconds before changing to the next one. and do this for 5 different steps.
    So it would look like

    step1.. wait 5 sec
    step2.. wait 5 sec
    step3.. wait 5 sec
    step4.. wait 5 sec
    step5.. wait 5 sec
    close form
    open another form

    Digging online the only thing i have been able to get to work is this but i cant get it to go passed 2 steps. I know it wasn't meant exactly for what i want to do but it comes close.

    Code:
    Sub Form_Timer()
        Static intShowPicture As Integer
        If intShowPicture Then
           
            Me!box1 = "1st step"
            
        Else
           
            Me!box1 = "2nd step"
        End If
        intShowPicture = Not intShowPicture
       
    End Sub

    any help will be greatly appreciated.

  2. Best Answer
    Posted by Missinglinq

    "You say 3 seconds, then you show 'wait 5 seconds'...set Timer Interval to either 3000 or 5000, depending on whichever you actually want! I'd actually use a Static Variable, as you have, rather than a Global Variable, then Select Case, as healdem suggested, like this:

    Code:
    Private Sub Form_Timer()
     
     Static DisplayTime As Integer
     
     Select Case DisplayTime
    
      Case 0
       Me.TextboxName = "message 1"
      
      Case 1
       Me.TextboxName = "message 2"
      
      Case 2
       Me.TextboxName = "message 3"
      
      Case 3
       Me.TextboxName = "message 4"
      
      Case 4
       Me.TextboxName = "message 5"
        
      Case 5
       DoCmd.OpenForm "SecondaryFormName"
       DoCmd.Close "CurrentFormName"
       
      End Select
    
    DisplayTime = DisplayTime + 1
    
    End Sub

    You don't say what you're using to start this process, and if the 5 second delay until the Timer starts up is too much, you might need to display the first message from elsewhere and adjust the Select Case to start at the second message.

    Linq ;0)>"


  3. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    So you need to know how long the current message has been active and wheter to change it and what to change it to.
    Theres several ways
    The simplest
    Declare a global variable to store the current message id, called say messageid
    Set the forms timer interval to 5 seconds, as it yses milliseconds
    Me.timetinterval =5000
    Then in your timerevent stub
    Select case messageid
    Case is 2:
    Me.box2 = "message 2"
    Case is 3:
    Me.box3 ="message 3"
    Case else: 'handles valye of 1 AND any out of range value so select will always work
    Me.box1= "message 1"
    Messageid =1
    End select
    Messageid = messageid + 1
    I'd rather be riding on the Tiger 800 or the Norton

  4. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    You say 3 seconds, then you show 'wait 5 seconds'...set Timer Interval to either 3000 or 5000, depending on whichever you actually want! I'd actually use a Static Variable, as you have, rather than a Global Variable, then Select Case, as healdem suggested, like this:

    Code:
    Private Sub Form_Timer()
     
     Static DisplayTime As Integer
     
     Select Case DisplayTime
    
      Case 0
       Me.TextboxName = "message 1"
      
      Case 1
       Me.TextboxName = "message 2"
      
      Case 2
       Me.TextboxName = "message 3"
      
      Case 3
       Me.TextboxName = "message 4"
      
      Case 4
       Me.TextboxName = "message 5"
        
      Case 5
       DoCmd.OpenForm "SecondaryFormName"
       DoCmd.Close "CurrentFormName"
       
      End Select
    
    DisplayTime = DisplayTime + 1
    
    End Sub

    You don't say what you're using to start this process, and if the 5 second delay until the Timer starts up is too much, you might need to display the first message from elsewhere and adjust the Select Case to start at the second message.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #4
    Join Date
    May 2016
    Posts
    9
    Provided Answers: 1
    Thanks for both solutions. I got it working now. I just realized i had 2 different times written in my original post. that was a goof on my part but i did have the timer interval set correctly. Thanks again for yalls help.

  6. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad we could help!

    Good luck with your project!

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •