Results 1 to 8 of 8
  1. #1
    OldAccessLearner is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2021
    Posts
    2

    Flashing Text

    Can someone please help me with my Access question?

    How do I get a text search box to flash on and off on copleting required search? I would like to do this with VBA code

    I have got the search working how I want it, but as above would like the end result to flash.

    I am only a novice and have self taught myself up to the stage that I am at currently.



    Thank you

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    start with the form timerInverval = 0 (off)
    when the search is done,
    set the forms timer interval =500 (500 milli secs)
    the code in the timer alternates the colors of the box:

    Code:
    Private Sub Form_Timer()
    If txtBox.BackColor = vbWhite Then
       txtBox.BackColor = vbYellow
    Else
       txtBox.BackColor = vbWhite
    End If
    End Sub
    


  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Similar idea to Ranman's but this makes the textbox visible or not

    Code:
    Private Sub Form_Timer()
    If Me.txtBox.Visible=True Then 
       Me.txtBox.visible=False
    Else
       Me.txtBox.visible=True
    End If
    End Sub
    This could be written more concisely but the above should be easy to understand
    Experiment with the timer interval which as already stated is in milliseconds. Personally I suggest 1000 (=1 second)

    I have an example app which includes flashing text (and much more): http://www.mendipdatasystems.co.uk/a...eek/4594398116
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    OldAccessLearner is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2021
    Posts
    2
    I already have an On Timer Event running on this form, as follows:- Private Sub Form_Timer
    [txtClock]=Now
    End Sub

    The Search code I am using is as follows:-Private Sub btnVehicleMakeSearch_click()
    Dim S As String
    S = InputBox("Enter Vehicle Make", "Vehicle Make Search Box", "")
    If S = "" Then Exit Sub
    Me.Filter = "VehicleMake Like ""*" & S & "*"""
    Me.FilterOn = True
    If Me.VehicleMake.BackColor = vbWhite Then
    Me.VehicleMake.BackColor = 655325
    End If
    If Me.VehicleMake.ForeColor = vbBlack Then
    Me.VehicleMake.ForeColor = vbBlue
    End If
    End Sub

    I hope you can figure out where I am trying to get to.

    Thanks

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    You can only have one Timer event on each form
    However if you are updating the date/time each second, you can just move your fore/back colour code to the timer event.

    If your timer event is updating every minute, things will get a bit more complicated
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  6. #6
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    have to wonder why you need this - searches on a properly designed db should be pretty quick - no more than a second or two. Although use of the initial * in your filter will slow things down a bit. Why not just use a combo to list the makes?

  7. #7
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I agree with Ajax. I don't see the purpose of trying to make the text box flash.

    But, you only have half of the code to make the control flash. The first time through there is a test if the backcolor of the control equals vbWhite. If it is, then the backcolor is set to 655325. the next time through the backcolor is NOT equal to vbWhite so nothing changes. The backcolor is stuck on 655325. You need to add an ELSE statement.
    Code:
    Private Sub btnVehicleMakeSearch_click()
        Dim S As String
        
        S = InputBox("Enter Vehicle Make", "Vehicle Make Search Box", "")
        If S = "" Then
            Exit Sub
        End If
        Me.Filter = "VehicleMake Like ""*" & S & "*"""
        Me.FilterOn = True
    
        ' ----- check backcolor   -----------
        If Me.VehicleMake.BackColor = vbWhite Then      ' << is backcolor = White?
            Me.VehicleMake.BackColor = 655325           '<< if yes, set backcolor to 655325
        Else
            Me.VehicleMake.BackColor = vbWhite          '<< if no, set backcolor back to vbWhite
        End If
       ' ----- check forecolor   -----------
        If Me.VehicleMake.ForeColor = vbBlack Then     ' << is forecolor = vbBlack?
            Me.VehicleMake.ForeColor = vbBlue           '<< if yes, set forecolor to vbBlue
        Else
            Me.VehicleMake.ForeColor = vbBlack         '<< if no, set backcolor back to vbBlack
        End If
    End Sub

  8. #8
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    Quote Originally Posted by ssanfu View Post
    I agree with Ajax. I don't see the purpose of trying to make the text box flash.

    But, you only have half of the code to make the control flash. The first time through there is a test if the backcolor of the control equals vbWhite. If it is, then the backcolor is set to 655325. the next time through the backcolor is NOT equal to vbWhite so nothing changes. The backcolor is stuck on 655325. You need to add an ELSE statement.
    Code:
    Private Sub btnVehicleMakeSearch_click()
        Dim S As String
        
        S = InputBox("Enter Vehicle Make", "Vehicle Make Search Box", "")
        If S = "" Then
            Exit Sub
        End If
        Me.Filter = "VehicleMake Like ""*" & S & "*"""
        Me.FilterOn = True
    
        ' ----- check backcolor   -----------
        If Me.VehicleMake.BackColor = vbWhite Then      ' << is backcolor = White?
            Me.VehicleMake.BackColor = 655325           '<< if yes, set backcolor to 655325
        Else
            Me.VehicleMake.BackColor = vbWhite          '<< if no, set backcolor back to vbWhite
        End If
       ' ----- check forecolor   -----------
        If Me.VehicleMake.ForeColor = vbBlack Then     ' << is forecolor = vbBlack?
            Me.VehicleMake.ForeColor = vbBlue           '<< if yes, set forecolor to vbBlue
        Else
            Me.VehicleMake.ForeColor = vbBlack         '<< if no, set backcolor back to vbBlack
        End If
    End Sub
    A Label Animation (Not TextBox) Demo database is attached. Enter a Number between 1 and 29 to the Customer ID Unbound TextBox at the Footer of the Customer Form and Click on <<Find Command Button for ***successful*** message and will flash for a few seconds. Greater than 29 will end up with an appropriate message flashing. Need more details visit the Link: https://www.msaccesstips.com/2009/04...h-success.html
    Attached Files Attached Files

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-27-2019, 07:49 AM
  2. Flashing Buttons??
    By matt_wpg in forum Forms
    Replies: 6
    Last Post: 04-04-2017, 03:04 PM
  3. Error keeps flashing
    By dniezby in forum Programming
    Replies: 2
    Last Post: 11-27-2016, 10:52 PM
  4. Flashing label
    By FJM in forum Access
    Replies: 45
    Last Post: 08-17-2016, 09:14 AM
  5. Replies: 2
    Last Post: 09-22-2014, 06:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums