Change BackColor

mdodge

Board Regular
Joined
May 3, 2004
Messages
97
Being new to VBA in Access, I have a general question about forms.

What would the code be for changing the BackColor of a TextBox when it becomes active? I suspect it is a GotFocus event.

Could this also be done in the TextBox Properties?
 
you would need to use both got/and lost focus
Code:
Private Sub Field2_GotFocus()
Me![Field2].BackColor = vbRed
End Sub

Private Sub Field2_LostFocus()
Me![Field2].BackColor = vbWhite
End Sub

HTH

Peter
 
Upvote 0
Thanks, Peter.

While I was waiting for a reply, I did some playing around and found the GetFocus and LostFocus events and used the code option to do the same thing as you suggested.

Only differance was I used the numerical properties of the colors.

Thanks again for your help.
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top