|
-
Dec 2nd, 2006, 08:18 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Command Button Help
See if i had one command button how would i get it to change captions when it has been clicked and when its been clicked it changed name and also opens up another new form i had this code in mind but it dosent seem to work.
VB Code:
Private Sub Command2_Click()
If Command2.Caption = "Search" Then
Form2.Show
ElseIf
If Command2.Caption = "Stop Search" Then
Form3.Show
End If
End Sub
-
Dec 2nd, 2006, 08:21 AM
#2
Re: Command Button Help
VB Code:
Private Sub Command2_Click()
If Command2.Caption = "Search" Then
[B]Command2.Caption = "Stop Search"[/B]
Form2.Show
ElseIf
If Command2.Caption = "Stop Search" Then
[B]Command2.Caption = "Search"[/B]
Form3.Show
End If
End Sub
-
Dec 2nd, 2006, 08:21 AM
#3
Re: Command Button Help
VB Code:
Private Sub Command2_Click()
If Command2.Caption = "Search" Then
Form2.Show
'ElseIf <-- This should be End If
End If
If Command2.Caption = "Stop Search" Then
Form3.Show
End If
End Sub
-
Dec 2nd, 2006, 08:22 AM
#4
Re: Command Button Help
VB Code:
Private Sub Command2_Click()
If Command2.Caption = "Search" Then
Command2.Caption = "Stop Search"
Form2.Show
End If
If Command2.Caption = "Stop Search" Then
Command2.Caption = "Search"
Form3.Show
End If
End Sub
Its because you wern't setting the caption after it had been clicked.
edit: also the end if is missing as pradeep said
-
Dec 2nd, 2006, 08:32 AM
#5
Re: Command Button Help
Oops missed the ElseIf part
-
Dec 2nd, 2006, 08:36 AM
#6
Re: Command Button Help
 Originally Posted by DigiRev
Oops missed the ElseIf part
And I missed the caption part
Anyways, You don't need 2 If's, one is sufficient.
VB Code:
Private Sub Command2_Click()
If Command2.Caption = "Search" Then
Command2.Caption = "Stop Search"
Form2.Show
Else
Command2.Caption = "Search"
Form3.Show
End If
End Sub
Pradeep
-
Dec 2nd, 2006, 08:39 AM
#7
Thread Starter
Frenzied Member
Re: [RESOLVED] Command Button Help
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
|