Make an object appear on button click

Zak14

Registered User.
Local time
Today, 13:37
Joined
Jun 27, 2014
Messages
166
What vba code would I use in the on click event of a command button to make another button appear?

Thanks.
 
Design the button in the Design view of the form set its Visible property to No. Then on the button click just set Visible of the second button to True. Something like.
Code:
Private Sub buttonName_Click()
    Me.buttonName2.Visible = True
End Sub
 
Complete aircode, but I think its something like

me.buttonname.visible = true
me.repaint 'Optional I believe

edit: *waves fist at PR2*
 
Design the button in the Design view of the form set its Visible property to No. Then on the button click just set Visible of the second button to True. Something like.
Code:
Private Sub buttonName_Click()
    Me.buttonName2.Visible = True
End Sub

Complete aircode, but I think its something like

me.buttonname.visible = true
me.repaint 'Optional I believe

edit: *waves fist at PR2*

Thanks it works. I didn't use the repaint thing though. What does it do?
 
Normally Repaint method is used when you have changed the caption or layout of the Form controls or the form itself. Since visibility is something different to editing the control by itself; it is not needed here.
edit: *waves fist at PR2*
@namliam : :p
 
Always unsure when to repaint or not, always need to actually test if it works without or not.
 
Repaint just forces the screen to catch up with appearance changes (not data related). If you have a lot of controls on your form and you're changing a lot of properties that affect looks and feel sometimes Access needs to catch up.
 
Tend to use repaint mostly when I am doing a lengthy do while ... loop displaying the progress.
Have found that if you do repaint too much it actually slows down your processing of the records considerably, thus I limit it to 50 or 100 itterations to do a repaint.
 
Tend to use repaint mostly when I am doing a lengthy do while ... loop displaying the progress.
Have found that if you do repaint too much it actually slows down your processing of the records considerably, thus I limit it to 50 or 100 itterations to do a repaint.
Yeah quite right that's why one should use it sparingly and I prefer DoEvents for my loops with a counter to indicate when to run the DoEvents.
 

Users who are viewing this thread

Back
Top Bottom