Hi Imran
I have not used pictures on command buttons as they are a new feature of
Access 2007. However, I believe you should be able to change them at
run-time simply by assigning another image file name to the Picture
property:
Me.cmdMyButton.Picture = "C:\Icons\NewIcon.ico"
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
Thanks for your guidance. Please guide me if we can also change the
picture
of the command button also indicating the maximize and minimize
position
along with changing the form position. Is there any specific property
of
the
form which should also be enabled for the form to be maximized or
restored?
:
Hi Imran
I'm sorry, I can't think of a reason for DoCmd.Maximize not to be
working.
Can you try creating a new form with nothing on it except the
cmdToggleMaximize command button, and the event procedure, and see if
it
works then?
For moving and resizing the form, check out DoCmd.MoveSize method, and
also
the form's InsideHeight and InsideWidth properties.
You should be aware that the units for all these methods and
properties
is
the "TWIP". Are TWIP is a "twentieth of a point", which means there
are
1440 per inch.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
Thank you for your valuable help. The caption of the button is
changing,
but
the form is not maximizing or minimizing. I have default menu bars
on
my
Access 2007 form. I'd be very greatful if you could indicate about
deficiency
which is not letting me make my form maximize or minimize by the use
of
the
command button. Is there any other way that we can programmatically
change
the dimensions of the form by clicking on the button. I am a novice
and
hence
appreciate your cooperation. Also please guide me about how to
remove
the
default menu items from the application.
:
Hi Imran
When you say "minimize", I assume you mean "restore". "Minimize"
means
reduce it to an icon at the bottom of the screen or on the task
bar,
so
you
wouldn't be able to see the button to maximize it again.
OK, so assuming you open the form in normal view (not maximized,
not
minimized) and you have a button named "cmdToggleMaximize" with the
caption
"Maximize form", you need a Click event procedure for that button:
Private Sub cmdToggleMaximize_Click()
With cmdToggleMaximize
If .Caption = "Maximize form" Then
DoCmd.Maximize
.Caption = "Make me small again"
Else
DoCmd.Restore
.Caption = "Maximize form"
End If
End With
End Sub
This procedure checks the caption of the command button you have
clicked
to
see if the form needs maximizing or not. If so, it maximizes it
and
changes
the caption. If not, it restores it and changes the caption back
again.
--
Good Luck
Graham Mandeno [Access MVP]
Auckland, New Zealand
message
Hi! I am working with MS Access 2007 and VBA code. I want to make
my
form
minimize and maximize programmatically with the help of a command
button.
At
the same time, moreover, I would like to change the label of my
button
as
such to indicate the current position of the form, either it is
maximized
or
mininmized. I'll appreciate valuable help in this regards. Thanks
in
advance.