Link to home
Start Free TrialLog in
Avatar of Milewskp
MilewskpFlag for Canada

asked on

How to make a checkbox control with a Null value appear white instead of greyed out.

Frm1 is based qry1. Qry1 is based on an outer join of tables tbl1 and tbl2 (the join is directed from tbl1 to tbl2). The controlsource of checkbox control chk1 on frm 1 is a boolean field of tbl2.

If there is no corresponding record in tbl2 for a given record in tbl1, then chk1 will appear greyed out (since it is Null). How can I make it appear white (False) when it has a Null valuel?
Avatar of DockieBoy
DockieBoy

Try using the Nz function,

Nz(MyControlSource,False)

Can you upload the db for a more specific answer :)
Avatar of Milewskp

ASKER

Hi Dockie,
Good suggestion, but Nz would make it read only, and in my case I need read write.
Hmm, my bad, I thought it was read only from the sounds of the query your form is based on, I don't use a lot of bound forms, but I'll have a quick play :)
Sorry, I have just re read your post and I just want to be sure.  You have a Left Outer Join and the check box is included in the results but is null because there is no record that maches the Join critera.

Not sure how you would be able to make changes to the value of this check box anyway?

Can you please provide an example :)
I have a solution for you. This solution requires you to add a dummy field to one the tables. If you are okay with that, please let me know to discuss it.

Mike
If the answer is yes, then add chkDummy to  tbl1 with Yes/No setting. Now, on your form, binde your checkbox (chkbox1) to this field not the one from tble2.

Also, on your form add chkbox2 to be binded to yes/no from table2. Make chkbox2 invisible.

In the Current event of the form, have:

If chkbox2 = true then
   chkbox2 = true
Else
   chkbox2 =False
End If

Mike
SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jim Dettman (EE MVE)

 Nice to see you around Mike :)

JimD.
Ditto :)
Thanks guys. I am here to learn some more from both of you.

Mike
Hi Mike,
Interesting idea. Thanks.  It got me thinking.

In my case the relationship between table1 and table2 is one-many, so changing the value of chkdummy in Table2 would affect multiple records on the form.
But, addingf the extra field to Table1 may be unneessary. What if chk1 is a calculated control:
= Nz([Chk2], False)

with OnClick event:
[chk2] = Nz([chk2], True)


- Your thoughts?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for your help folks, I'll go with my solution and give the assist to Mike.
Milewskp<

My appology for not responding earlier.

If you have a solution that you like that is fantastic. FYI, adding chkDummy and data in it is of no conseqyence (this is why it ia called dummy). The reason we wanted to have it so that the the visible check box is bound to something (this is essential if you are showing multible records in detail section).

This dummy checkbox, nonetheless, displays the accurate data from theother table. Also, just in case, you wanted to upload a sample datbase, I will be glad to work with you on it.

Regards,

Mike
Hi Mike,
I'm satisifed that this question is closed, but if you'd like to discuss further, post away.

Thanks again.
.