15 pts.
 Toggle button
I have two command buttons, CmdNew and CmdOld, where by clicking the first i make the second visible and vice versa for example Private Sub CmdNew_Click() Me!CmdOld.Visible = True End Sub I want to use only one toggle button instead,with two captions"Old" and "New". I have difficulties with making the buttons visible and invisible.Also.if i click New, the caption Old must appear and stay until i have clicked it.If i click Old, the caption Old must appear and stay until i click it. How could i do that ?

Software/Hardware used:
ASKED: January 24, 2009  12:30 PM
UPDATED: January 26, 2009  3:20 PM

Answer Wiki:
Instead of making two buttons, why not make one button that toggles its state? You can use the current caption to see what state it was in when it was clicked, and take the appropriate actions -- including switching the caption. Eg: <pre>Option Explicit Const BTN_CAP_NEW As String = "New" Const BTN_CAP_OLD As String = "Old" Private Sub btn_Click() If (btn.Caption = BTN_CAP_NEW) Then ' Actions if the "New" button was clicked ' ... btn.Caption = BTN_CAP_OLD Else ' Actions if the "Old" button was clicked ' ... btn.Caption = BTN_CAP_NEW End If End Sub</pre>
Last Wiki Answer Submitted:  January 26, 2009  3:20 pm  by  YuvalShavit   905 pts.
All Answer Wiki Contributors:  YuvalShavit   905 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _