Hi Guys,
Is it possible to call a Button click even within another button click event?
Something Like the following
VB Code:
Private Sub CmdAdd_click() If Mode = "Edit" then CmdMod_click End If End Sub
Printable View
Hi Guys,
Is it possible to call a Button click even within another button click event?
Something Like the following
VB Code:
Private Sub CmdAdd_click() If Mode = "Edit" then CmdMod_click End If End Sub
Try for it .... it is possible.... :bigyello:Quote:
Originally Posted by vasanth2979
Actually why you are doing like this make a sub or the function for the repeat code
Certainly
VB Code:
Private Sub Command1_Click() MsgBox 1 Command2_Click End Sub Private Sub Command2_Click() MsgBox 2 End Sub
i actually made a sub and tried to save Data but the prob is the Save function works fine when save button is clicked but not when its corresponding short cut key is pressed( Alt + S)
Yes u can call button click event within a button click event. It is the same like you are calling a function within a function.VB Code:
Private Sub CmdAdd_click() If Mode = "Edit" then CmdMod_click End If End Sub
Are you sure the caption on the button is &Save?Quote:
Originally Posted by vasanth2979
Yes I use the same button for Save and Add. If the caption is Add it creates a new row in the table and if caption is save it saves it
Are you sure that when you change the caption to Save, you have the '&' in front of the S?
The following code works for me:When the button says Save, I can hit it with alt-S, when it says Load, I can hit it with alt-L.VB Code:
Private Sub cmd1_Click() If cmd1.Caption = "&Save" Then MsgBox "Save" cmd1.Caption = "&Load" ElseIf cmd1.Caption = "&Load" Then MsgBox "Load" cmd1.Caption = "&Save" End If End Sub Private Sub Form_Activate() cmd1.Caption = "&Save" End Sub
Thanks Mate,
I was missing the '&'