how to disable a button if ...

  • Thread starter Thread starter jd
  • Start date Start date
J

jd

Dear All

I have a 2000 database with records of about 2000 people.
I have a file with portraits of about 300 of them, some
of them with more than one portrait.

I've made a form which gives all the basic information,
but I don't want to use space on portraits which may
not exist. So I made a button which opens up the table of
portraits. It is linked by 'id' which appears as the key
in the main table, as a filed in the portraits table.

I want to disable the button if the person on the form
has no portrait ---save users the trouble of clicking
and getting a blank return. I guess the code should
check each time a new person-form opens whether the
person has a portrait or not, and enables or disables
the button accordingly.

I have no idea how to do this. If someone could point
me a source for this, I'd learn a useful thing, and
improve my form, and be very grateful.

Many thanks.
--
John Davis
All Souls College
Oxford
+44 (0) 1865 279300
(e-mail address removed)
 
jd said:
Dear All

I have a 2000 database with records of about 2000 people.
I have a file with portraits of about 300 of them, some
of them with more than one portrait.

I've made a form which gives all the basic information,
but I don't want to use space on portraits which may
not exist. So I made a button which opens up the table of
portraits. It is linked by 'id' which appears as the key
in the main table, as a filed in the portraits table.

I want to disable the button if the person on the form
has no portrait ---save users the trouble of clicking
and getting a blank return. I guess the code should
check each time a new person-form opens whether the
person has a portrait or not, and enables or disables
the button accordingly.

I have no idea how to do this. If someone could point
me a source for this, I'd learn a useful thing, and
improve my form, and be very grateful.

Many thanks.
Use a hidden control on your form for the ID, bind it to the ID field in
the table.
In the OnCurrent do something like below. It depends on the datatype
of the
ID field in your table and how you are using the field as to how you
test the field.
This is just an example of different combinations of testing. If the
field is a
numeric field you may only need the test for zero. If it is an text
field you may
require one or more

If IsNull( Me!ID ) or IsEmpty( Me!ID ) or Me!ID=0 or Me!ID="0" or
Me!ID=" " or Me!ID="" then
Me!btnPicture.Enabled=False
Else
Me!btnPicture.Enabled=True
EndIF

HTH,
Ron
 
Back
Top