Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flagging to turn on/off a button 1

Status
Not open for further replies.

valgore

Technical User
Nov 12, 2008
180
US
i have a button on a form called button1. what i want to happen is say when button2 is clicked, enable button1. as soon as button1 is click, disable it until button2 is clicked again. the reason for doing this is so that someone doesnt press button1 more than once between button2 clicks.

Hope this makes sense!

Valgore
 
I think the Enable may work here.
in the Onclick() try
btn2.Enable=true
btn1.Enable=false

htwh,


Steve Medvid
IT Consultant & Web Master

Chester County, PA Residents
Please Show Your Support...
 
ok so that looks pretty straight forward. but i need it to say
If btn1.click=true(or whatver that syntax is) then btn1.Enable=false until btn2.click=true then btn1.enable=true

can you help me with the true syntax for that? im a bit of a novice programmer.

Valgore
 
htwh,


Code:
Private Sub cmd_Button_1_Click()
On Error GoTo Err_cmd_Button_1_Click
    Me.cmd_Button_2.Enabled = True
    Me.cmd_Button_2.SetFocus
    'SetFocus Required, since can't disable
    'Control that has present Focus!
    Me.cmd_Button_1.Enabled = False
'Or Use Visible Property as opposed to Enabled?
    
Exit_cmd_Button_1_Click:
    Exit Sub

Err_cmd_Button_1_Click:
    MsgBox Err.Description
    Resume Exit_cmd_Button_1_Click
    
End Sub
Private Sub cmd_Button_2_Click()
On Error GoTo Err_cmd_Button_2_Click
    Me.cmd_Button_1.Enabled = True
    Me.cmd_Button_1.SetFocus
    'SetFocus Required, since can't disable
    'Control that has present Focus!
    Me.cmd_Button_2.Enabled = False
'Or Use Visible Property as opposed to Enabled?
    
Exit_cmd_Button_2_Click:
    Exit Sub

Err_cmd_Button_2_Click:
    MsgBox Err.Description
    Resume Exit_cmd_Button_2_Click
    
End Sub

Steve Medvid
IT Consultant & Web Master

Chester County, PA Residents
Please Show Your Support...
 
wow. that was WAY too easy. thank you so much. i altered your code a little bit, but it gave me what i wanted.
Thanks again!

Valgore
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top