Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

buttons form

ResolvedVersion 2010

Stuart has attended:
Access Intermediate course
Access Advanced course
Access VBA course

Buttons on a form

Hi,

I have a form with a few buttons and whilst tabbing through them it's very difficult to see which button I'm on. Is there a way to highlight/change the colour of the button in the same way a button can change colour when hovering over it with the mouse?

Edited on Tue 16 Jul 2013, 11:42

RE: Buttons on a form

Hello Stuart,

Hope you enjoyed your Microsoft Access courses with Best STL.

Thank you for your question regarding changing the colour of a button when tabbing onto it.

The following code does this for a command button named cmdCloseForm2 containing text items as opposed to images. It works!

First select the command button and from the Event section of the Property sheet click the ... in the On Got Focus row and use the code below. You must amend the part 'cmdCloseForm2' to whatever you have named your button. Colour choices are also up to you.

Private Sub cmdCloseForm2_GotFocus()
cmdCloseForm2.FontSize = 9
cmdCloseForm2.FontBold = True
cmdCloseForm2.ForeColor = vbRed
cmdCloseForm2.BackColor = vbYellow
End Sub


Private Sub cmdCloseForm2_LostFocus()
cmdCloseForm2.FontSize = 10
cmdCloseForm2.FontBold = False
cmdCloseForm2.ForeColor = vbBlack
cmdCloseForm2.BackColor = vbWhite
End Sub

Access will automatically place the second bit of code into the Lost Focus row in the Property sheet.

Give this a test and let me know how it works for you.

I hope this resolves your question. If it has, please mark this question as resolved.

If you require further assistance, please reply to this post. Or perhaps you have another Microsoft Office question?

Have a great day.
Regards,

Rodney
Microsoft Office Specialist Trainer

RE: Buttons on a form

Rodney to the rescue again!

Thanks again for your time and expertise!

Stuart

Access tip:

Space marks

It is good practice not i to have space marks for field names as this can lead to problems when using queries or VBA code. It is much better to use an underscore charcter to represent spaces in field names

View all Access hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.