Is that possible for me to enable or disable any control using iif
condition from the control source of a control in a access form?
Let me explain the problem. I have an Access form whose record source is a
SQL Query. The form have several Check boxes whose control source are
different fields from the query used in record source. This is very normal.
Now I have to enable or disable each check box depending upon a fild value
say "objnumber" which is also coming from the record source query. How can I
do that. I tried writing expresion in the control source property of each
check box with Expression Builder like -
iif(objnumber="16",chkCheckBox1.enabled="false",chkCheckBox1.enabled="true")
but that does not help more over I have to show the query field data also in
the checkbox.
Please help me
Thanks and Regards
Kaushik
With Me
If .NewRecord Then
.CheckBox1.Enabled = True
.CheckBox2.Enabled = True
Else
.CheckBox1.Enabled = Some Condition
.CheckBox2.Enabled = Some Condition
End If
End With
--
Dave Hargis, Microsoft Access MVP
In an event procedure for the form's "Current" event (i.e., "OnCurrent"),
you can add something like (untested):
Me!chkCheckBox1.Enabled = (Me!objnumber = 16)
Me!chkCheckBox2.Enabled = (Me!objnumber = 16)
...
(or ... = Not (Me!objnum...))
Or more elegantly, if you have several checkboxes to set, you could create a
variable in the event procedure and use that to do the setting, something
like (also untested):
Dim blnEnable as Boolean
blnEnable = (Me!objnumber = 16)
...
Me!chkCheckBox1.Enabled = blnEnable
...
Good luck!
--
Regards
Jeff Boyce
www.InformationFutures.net
Microsoft Office/Access MVP
http://mvp.support.microsoft.com/
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
"Kaushik" <Kau...@discussions.microsoft.com> wrote in message
news:3422C151-C995-4313...@microsoft.com...
Klatuu,
It seems I couldnot make you understand my problem.Say I have 100
records that are coming from the record source query. So 100 check boxes are
generating. Each of these records have fields named "ObjNumber" and
"RCSub1". "RCSub1" is a boolean field and it's value gets reflected in
"RCCheck1" check box. As I have 100 records so 100 "RCCheck1" check boxes
will generate. Now I have to see each "ObjNumber" field and if the valeu of
any record in those 100 records is "16" then the corresponding CheckBox will
be disabled.
I tried your solution but current event not at all generating any new
record so at the time of opening the If loop is encountered and the control
flow is getting out.
Also the current event of the form is fired only once in time of opening,
how come I can check for "ObjNumber" field for 100 records there.
Please Let me know If You have any solutions
Thanks and Regards
Kaushik