NewbieVBA
NewbieVBA

Reputation: 47

Type Mismatch when trying to change background color through an event in Ms Access

I have a simple button in MS Access form that I require to have the background color changed and remain once the button is pressed and the mouse is no longer hovering. So, Blue static, Green on Hover, Red once pressed and remains red. I have the hover and press controls set and all work fine. But I get a mismatch error when trying to change the backcolor during the procedure.

Private Sub OpenBtn_Click()
   OpenBtn.BackColor = "#ED1C24"
   DoCmd.OpenForm "Customer"
End Sub

I Know I'm not using the write ' or " or & somewhere... any help is greatly appreciated.

Upvotes: 0

Views: 857

Answers (1)

Sergey S.
Sergey S.

Reputation: 6336

Color is not string, you need to provide Long for BackColor. Use RGB function:

OpenBtn.BackColor = RGB(255, 0, 0) 'red color

Upvotes: 1

Related Questions