Button visible/invisible in a Continuous Form

joeschwa

Registered User.
Local time
Today, 08:19
Joined
Aug 24, 2015
Messages
10
I have a Continuous Form, and I have a command Button by the site of each record, also I have a yes/no box in each record

can I make the button visible/invisible depend of the box if its true or false "again its a Continuous Form"

thanks all
 
I don't think so. You could probably fake it by using a text box and use Conditional Formatting to either disable or hide it (by setting fore color = to back color).
 
you could easily add code to the button click to test whether it should activate or not.

you could enable/disable the button in the current event, although the effect can look odd on a continuous form.
 
I don't think so. You could probably fake it by using a text box and use Conditional Formatting to either disable or hide it (by setting fore color = to back color).

thanks

did you mean to use the text box For the button ??
 
thanks

did you mean to use the text box For the button ??

Yes; I'm pretty sure Conditional Formatting can't be applied to a button. Dave's suggestion would work, but every button would have the same look as the active record (the odd look he mentioned).
 
thinking again, you can have clickable labels, as opposed to buttons.

I expect you could format a label with conditional formatting.

You can even use clickable transparent labels as overlays - although I doubt if that would be so useful here.
 
Unless something has changed, Conditional Formatting can't be used on buttons or labels. A label would have been my first choice after a button, but in 2010 CF is grayed out when a label is selected.
 
well then you could have a disabled textbox, and overlay that with a transparent clickable label, and able CF to the text box.

That might all work.
 
don't think you can - your get an error 'you can't change the value of this property in the OnPaint event'

what code have your tried?
 
I know this thread is really old but because it is the first result on google:
You can set your buttons "Transparent" Option in your OnPaint Event of your Form Detail Section.

Welcome to the site. I'd be curious to see a working example of that. I'd expect an error in a form.
 
Sorry, slow fingers.
 
Hi Saphirah
Welcome to AWF and thanks for this idea.
After testing I can confirm it really does work.

SQL:
Private Sub Detail_Paint()
   Me.cmdButton.Transparent = Me.chkBox
End Sub

Capture.PNG

@CJ_London
You get that error if you try and set the button visible property
 
I have to admit I was also sceptical and originally tried setting the visible property which caused the error noted by @CJ_London.
However what you described really does work.

Well done. That's a problem that has defeated many of us for years....and the solution is so simple...😎
 
Works but button is still clickable. So an accidental muscle spasm while moving mouse across form could have undesirable results.
Probably need the procedure to deal with that.
 
Last edited:
Works but button is still clickable. So an accidental muscle spasm while moving mouse across form could have undesirable results.
I would prefer a textbox formatted to look like button and/or hyperlink and use CF to enable/disable.

That's easily fixable. For example:
SQL:
Private Sub cmdButton_Click()
  If Not Me.ChkBox Then MsgBox "You clicked the button"
End Sub

Private Sub Detail_Paint()
    Me.cmdButton.Transparent = Me.chkBox
End Sub
 
That's easily fixable. For example:
SQL:
Private Sub cmdButton_Click()
  If Not Me.ChkBox Then MsgBox "You clicked the button"
End Sub

Private Sub Detail_Paint()
    Me.cmdButton.Transparent = Me.chkBox
End Sub
Or even do nothing?
 
@Gasman
The point was in response to @June7's comment about an unintended button click due to a 'muscle spasm'
It was intended to show code that would only run if the button transparent property was false
 
must admit, I've never used the transparent property before (or the paint event for that matter on forms). Would seem you can't rely on the value of the transparent property to determine whether to ignore if transparent=true, so as suggested, would need to use the same boolean that determines whether the button is transparent or not.

Note the paint event is triggered on a form resize event as well as scrolling
 
Late to the party as usual, only just found this - works a treat!
 

Users who are viewing this thread

Back
Top Bottom