View Full Version : enable command button if Female


Muneer
08-14-2000, 05:57 AM
Hello every one
I have a main form shoing medical information and a Button to add Pregnancy info,
How can I disable the command button If the Sex Field is "Male"
any solution
Thank youn all

gino
08-14-2000, 07:19 AM
first have the command button not enabled in the properties. second put this code in the appropiate event where you need this validation to take action.

if me.sexfield ="female" then
me.commandbutton.enabled = true
else
'do nothing
end if

i'm thinking maybe in the OnOpen event!

modify this if you must.
have fun!

mikec
08-14-2000, 07:22 AM
Muneer,

In the OnCurrent event of the form, put the folowing code:

If me.genderfieldname = "Female" Then
me.cmdbuttonname.enabled = True
Else me.cmdbuttonname.enabled = False
End If

This will turn the button on and off as you cycle through the records.

You'll also want to put the same code in the AfterUpdate event of the gender field so that when the record is first created, the button will be correct when that field is first populated.

Regards,

Mike

Richie
08-14-2000, 10:37 AM
Put Form_Current in the after update of the sex field