- database solutions and downloads for microsoft access

Microsoft Access Command Buttons

Creating Custom Command Buttons

When creating a Microsoft Access User Interface, and adding the standard Access command buttons does not give too many options for customising the look of the interface.

The problem is that when using a bitmap to use as a "skin" for the button, there is still a grey border around the bitmap once it is on the command button. If you are using custom background colors as well it doesn't look very nice having a nice looking command button that still has a grey boarder.

What you can do is forget about the button all the way and simply place your image on the form, then use its OnClick event to start the desired action.

You can still get the animation with this option. By creating an image box and loading in the picture for your command button, then on the Mouse Down event add the code:

Private Sub Image1_MouseDown(Button As Integer, _
    Shift As Integer, _
    X As Single, Y As Single)

' Special Effect 2 shows effect of Sunken
    Image1.SpecialEffect = 2
End Sub

And on the Mouse Up event add

Private Sub Image1_MouseUp(Button As Integer, _
    Shift As Integer, _
    X As Single, Y As Single)
' Special Effect 1 shows effect of Raised
    Image1.SpecialEffect = 1
End Sub

where Image1 is the name of the image control, this will make the image indent when pressed AND get rid of the undesirable border. You can also make the picture change when the button is pressed by adding a line of code:

imageboxcontrol.picture = "C:\etc..."

When you want the picture to change, or overlap two embedded image controls and sequentially change their visibility properties.


The SpecialEffect property uses the following settings.

Setting Visual Basic Description
Flat 0 The object appears flat and has the system's default colors or custom colors that were set in Design view.
Raised 1 The object has a highlight on the top and left and a shadow on the bottom and right.
Sunken 2 The object has a shadow on the top and left and a highlight on the bottom and right.
Etched 3 The object has a sunken line surrounding the control.
Shadowed 4 The object has a shadow below and to the right of the control.
Chiseled 5 The object has a sunken line below the control.

Why not check out the following for much more information on using VBA in Microsoft Access: