Question: I want some records in my Access Datasheet Form to flash (switch from one color to another one) depending on the value in a given field.

I found some great help on [there](https://www.techonthenet.com/access/forms/flashing2007.php) by using the On Timer event of the Form but for some reason it doesn't work for me.
I suppose it is because in my case, my form is displayed in **Datasheet View**.

Also, I realized that it only checks the value of the active record but I would like it to check the value of all the records for that given field (via SQL maybe ?)

Is it even possible to change the back color of a record via VBA in Access or the only way is via the conditional formatting tool ?

I am a bit confused on how to proceed and if there is even a way to do so.

Any ideas on how to do this ?

```
Private Sub Form_Timer()

   If [Receiver] = "Martin" Then
       If [Receiver].ForeColor = 0 Then 'vbRed
          [Receiver].ForeColor = 255 'vbBlack
       Else
          [Receiver].ForeColor = 0 'vbRed
       End If
   End If

End Sub

```

Answer: 
You are adding target to `UIImageView`, it's not work please check below code 

```
    let btn1 = UIButton(type: .custom)
    btn1.setImage(UIImage(named: "imagename"), for: .normal)
    btn1.frame = CGRect(x: 0, y: 0, width: 30, height: 30)
    btn1.addTarget(self, action: #selector(openMaps), for: .touchUpInside)
    let item1 = UIBarButtonItem(customView: btn1)

    self.navigationItem.setRightBarButtonItems([item1], animated: true)

```
I want to add a different approach.

You can create some custom bar item class and write your specific initializer for customView. For example;

```
fileprivate class BarButtonItem: UIBarButtonItem {

    @objc func buttonAction()

    override init() {
        super.init()
    }

    convenience init(customView: UIControl) {
        self.init()
        self.customView = customView
        customView.addTarget(self, action: .onBarButtonAction, for: .touchUpInside)
    }

fileprivate extension Selector {
    static let onBarButtonAction = #selector(BarButtonItem.buttonAction)
}

```

And with this way, you can even add closure inside your buttonAction.

```
var actionCallback: ( () -> Void )?
    @objc func buttonAction() {
        actionCallback?()
    }

```