Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Flashing text!

  1. #1
    Join Date
    Oct 2011
    Posts
    45

    Unanswered: Flashing text!

    I Finally solved my first problem , thank you so much friends...but as they say new solution, finds another problem. I just wanna know how can i make the text blink or flash with another color whenever i click the button NEXT, then make the blink stop after 10 seconds? I tried using this one:

    Private Sub Form_Timer()
    With Counter17
    .ForeColor = (IIf(.ForeColor = 14013951, 106, 14013951))
    Static iCount As Integer
    iCount = iCount + 1
    If iCount = 10 Then
    Me.TimerInterval = 0
    Exit Sub
    End If

    End With

    End Sub



    It did blinked/flashed after i opened the form and stop after 10 seconds but after i clicked NEXTRecord, it wont do the command. Any suggestions? Thank you friends. Attached is my sample project.
    Attached is my sample project. Thank you.
    Attached Thumbnails Attached Thumbnails untitled.JPG  
    Last edited by dennis_ian; 10-18-11 at 05:35.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You could use:
    Code:
    Private Sub Command_Next_Click()
    
        Me.TimerInterval = 125  ' 125 ms. --> blinks 4 times/second.
        
    End Sub
    
    Private Sub Form_Timer()
    
        Static lngCounter As Long
        
        Me.Text0.BackColor = IIf(Me.Text0.BackColor = vbRed, vbWhite, vbRed)
        lngCounter = lngCounter + 1
        If lngCounter = 80 Then ' 8 * 125 ms = 10 s. --> total blinking duration.
            lngCounter = 0
            Me.TimerInterval = 0
        End If
        
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Oct 2011
    Posts
    45
    hi Sinndho..when i tried the code, this thing popped out.Attached is the error.
    Attached Thumbnails Attached Thumbnails error.JPG  
    Last edited by dennis_ian; 10-18-11 at 20:38.

  4. #4
    Join Date
    Oct 2011
    Posts
    45
    Could it be that this portion of the event has something to do with the error. I inserted a dingdong sound whenever i click the Next button. Is it possible that with the sounds comes the flashing of the text?
    Attached Thumbnails Attached Thumbnails error2.JPG  

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If Nextc17 is the name of the command button that is used to move from one record to the next, the functions I provided for flashing a textbox are not used at all.

    The event handler for that button must include the line:
    Code:
    Me.TimerInterval = 125
    You also have to ensure that the event handler for the Timer event of the form:
    Code:
    Private Sub Form_Timer()
    is correctly associated with the OnTimer property of the form.

    Finally, you need to replace the name of the textbox in:
    Code:
    Me.Text0.BackColor = IIf(Me.Text0.BackColor = vbRed, vbWhite, vbRed)
    by the actual name of the control in your form.

    If you want to be able to debug the code, begin by disabling the error-trapping mechanism, so that the execution will stop on all errors. In the Sub Nextc17_Click procedure you don't handle errors, you just ignore them.
    Have a nice day!

  6. #6
    Join Date
    Aug 2006
    Posts
    52
    i am new to vba, just want to ask, is this the correct way to write IF statement or does IIF do a new function

    you wrote IIf

    sorry, just asking coz i also need to use timer to make a flash screen and will need to use similar code i think

  7. #7
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by oakeyes View Post
    i am new to vba, just want to ask, is this the correct way to write IF statement or does IIF do a new function

    you wrote IIf

    sorry, just asking coz i also need to use timer to make a flash screen and will need to use similar code i think
    If and IIF are two different things:
    Code:
    IF SomethingElse = SomeValue Then
    
        ' Statements to be executed when the condition is True
        '
        Something = ValueForSomethingWhenConditionIsTrue
    Else
    
        ' Statements to be executed when the condition is False
        '
        Something = ValueForSomethingWhenConditionIsFalse
    End If
    Code:
    Something = IIf(SomethingElse = SomeValue, ValueForSomethingWhenConditionIsTrue, ValueForSomethingWhenConditionIsFalse)
    For a full explanation about both, use Access Help (F1 key).
    Have a nice day!

  8. #8
    Join Date
    Oct 2011
    Posts
    45
    hi Sinndho, thank u again for the reply. But unfortunately, am still getting the same error. I dont know why. )=

  9. #9
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Copy the code you use and paste it in your next message, or attach a zipped copy of your database to it.
    Have a nice day!

  10. #10
    Join Date
    Oct 2011
    Posts
    45
    hi Sinddho,

    Here's the code that i used.

    Private Sub Nextc17_Click()

    Me.TimerInterval = 125 ' 125 ms. --> blinks 4 times/second.

    End Sub

    Private Sub Form_Timer()

    Static lngCounter As Long

    Me.Text16777215.BackColor = IIf(Me.Text16777215.BackColor = vbRed, vbWhite, vbRed)
    lngCounter = lngCounter + 1
    If lngCounter = 80 Then ' 8 * 125 ms = 10 s. --> total blinking duration.
    lngCounter = 0
    Me.TimerInterval = 125
    End If




    End Sub


    Private Sub Nextc17_Click()


    Playsound ("C:\Documents and Settings\dlsu\My Documents\Downloads\doorbell-1.wav")



    On Error GoTo Err_Nextc17_Click


    DoCmd.GoToRecord , , acNext

    Exit_Nextc17_Click:
    Exit Sub

    Err_Nextc17_Click:
    MsgBox Err.Description
    Resume Exit_Nextc17_Click



    End Sub

  11. #11
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. You cannot have two procedures with the same name in the sale module, which is the case in your database:
    Code:
    Private Sub Nextc17_Click()
    can be found twice in the code you sent. I bet that your code cannot be compiled because of that. Merge the instruction from both procedures into a single one.

    2. Where is the function Playsound declared and how? The way you use it, two parameters are missing that, according to MSDN (PlaySound function) are not optional. Remove or comment that line and try again.
    Have a nice day!

  12. #12
    Join Date
    Oct 2011
    Posts
    45
    hi Sinddho.

    I appreciate you sticking with me. I apologize its taking this long...)=

    i merged the code. Is this right? or am i missing on something. am still getting the same error.



    Private Sub Nextc17_Click()

    Me.TimerInterval = 125 ' 125 ms. --> blinks 4 times/second.


    Playsound ("C:\Documents and Settings\dlsu\My Documents\Downloads\doorbell-1.wav")


    On Error GoTo Err_Nextc17_Click


    DoCmd.GoToRecord , , acNext

    Exit_Nextc17_Click:
    Exit Sub

    Err_Nextc17_Click:
    MsgBox Err.Description
    Resume Exit_Nextc17_Click



    End Sub




    With regards to your second second question, i got the code from the net which i inserted in a module. Attached is how i did it.
    Attached Thumbnails Attached Thumbnails untitled.JPG  

  13. #13
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Unfortunately, I cannot help without knowing precisely what happens.

    1. Disable the error trapping mechanism (in the VBA Editor choose Options from the Tools menu, open the General tab and in the Error Trapping frame select Break on all errors.

    2. Compile the project, then run your code.

    3. Post a message with the line where the error occurs, the error message (code and description).
    Have a nice day!

  14. #14
    Join Date
    Oct 2011
    Posts
    45
    Sinddho, would it be ok if i send you a copy of the database so you could personally check the error ? if you dont mind? (=

  15. #15
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Sure ! Do that.
    Have a nice day!

Posting Permissions

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