|
-
Sep 28th, 2006, 04:42 AM
#1
Thread Starter
Lively Member
[Resolved]Button Click Event within another
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
Last edited by Hack; Sep 29th, 2006 at 06:11 AM.
Reason: Added green "resolved" checkmark Last edited by vasanth2979 : Yesterday at 07:05 AM
-
Sep 28th, 2006, 04:52 AM
#2
Re: Button Click Event within another
 Originally Posted by vasanth2979
Hi Guys,
Is it possible to call a Button click even within another button click event?
Try for it .... it is possible.... 
Actually why you are doing like this make a sub or the function for the repeat code
-
Sep 28th, 2006, 05:06 AM
#3
Lively Member
Re: Button Click Event within another
Certainly
VB Code:
Private Sub Command1_Click()
MsgBox 1
Command2_Click
End Sub
Private Sub Command2_Click()
MsgBox 2
End Sub
-
Sep 28th, 2006, 05:07 AM
#4
Thread Starter
Lively Member
Re: Button Click Event within another
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)
-
Sep 28th, 2006, 05:11 AM
#5
Hyperactive Member
Re: Button Click Event within another
VB Code:
Private Sub CmdAdd_click()
If Mode = "Edit" then
CmdMod_click
End If
End Sub
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.
-
Sep 28th, 2006, 10:15 AM
#6
Re: Button Click Event within another
 Originally Posted by vasanth2979
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)
Are you sure the caption on the button is &Save?
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Sep 28th, 2006, 11:09 PM
#7
Thread Starter
Lively Member
Re: [Resolved]Button Click Event within another
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
-
Sep 29th, 2006, 11:02 AM
#8
Re: [Resolved]Button Click Event within another
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:
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
When the button says Save, I can hit it with alt-S, when it says Load, I can hit it with alt-L.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Sep 29th, 2006, 11:25 PM
#9
Thread Starter
Lively Member
Re: [Resolved]Button Click Event within another
Thanks Mate,
I was missing the '&'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|