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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you conditionally disable buttons? 1

Status
Not open for further replies.

djayam

Technical User
Aug 16, 2005
95
GB
Hi all,

Is there a way of either hiding or disabling buttons on a form based on the value of a control? I can only see a global yes/no selection for each button.

Cheers,

Jason
 
You would have to do this in code. Something like....

If me.somecontrol = "x" then
me.mybutton.enabled = false
else
me.mybutton.enabled = true
end if

This would go in either or both of the Form_Current event procedure and the 'somecontrol' afterupdate event procedure.
 
You can hide or disable

me.buttonname.visible = me.textbox1="condition"
me.buttonname.enabled = me.textbox1="condition"
 
Sorry Lupins46 you must have been posting while I was typing
 
Thanks loads guys - I'll try it out and let you know.

Thanks again,

Jason
 
Right - almost there...

I didn't mention my form is a continuous form. I have the code working but it affects all detail records - any way to have it only affect the relevant record?

Also, I can't get it to work immediately the form is loaded - it only changes the enabled property when you click the button (I have tried the code in the On Current and On Load events.

Cheers,

Jason
 
You cannot do this on a continuous form.

What you would need to do is to simulate a button using a textbox control. Use the textbox's Click event as you would for the button.
The use conditional formatting on the textbox to enable or disable the textbox, based on the value in the other control.
 
Ah!! Lateral thinking...thanks for that Lupins.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top