Disable Button If

S

Supe

Is there a way to Disbable a Button if there is any information in any of a
number of different fields?
 
O

Ofer Cohen

Try something like

Me.ButtonName.Enabled = (IsNull(Me.FieldName1) And IsNull(Me.FieldName2))

If any of the fields, field1 or field2, wont be empty the button will be
disabled, else if both empty it will be enabled.

Run this code on the after update event of the text boxes
 
S

strive4peace

yes,

you can use the form current event to test values:

'~~~~~~~~~~~
Private Sub Form_Current()
dim mBoo as boolean
mBoo = true
if me.controlname = somevalue then mBoo = false
if me.fieldname = somevalue then mBoo = false
if someOthercondition then mBoo = false
'etc
me.CommandButton_controlname.enabled = mBoo
End Sub
'~~~~~~~~~~~

you can use the AfterUpdate event of particular control to switch the
enabled status during form entry

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
S

strive4peace

If you change the data in text boxes using code or by changing the
record, the AfterUpdate event will not be run

also put the code on the form Current event so it runs when records change

if you use code to change values, add this to your code as well

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
Top