Solved

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

Posted on 2011-03-18
16
539 Views
Last Modified: 2013-11-28
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?
0
Comment
Question by:Milewskp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
  • +2
16 Comments
 
LVL 3

Expert Comment

by:DockieBoy
ID: 35169770
Try using the Nz function,

Nz(MyControlSource,False)

Can you upload the db for a more specific answer :)
0
 
LVL 1

Author Comment

by:Milewskp
ID: 35170010
Hi Dockie,
Good suggestion, but Nz would make it read only, and in my case I need read write.
0
 
LVL 3

Expert Comment

by:DockieBoy
ID: 35170112
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 :)
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 3

Expert Comment

by:DockieBoy
ID: 35170161
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 :)
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 35173308
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
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 35173338
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
0
 
LVL 34

Assisted Solution

by:Mike Eghtebas
Mike Eghtebas earned 500 total points
ID: 35173363
Word of caution...

In the existing grayed out check box version, please test VarType of the check box when it is grayed out. In the Current even of form prior to applying my solution have:

MsgBox VarType(Me!chk1)

It may produce 9 when it is grayed out. Object VarType is 9. If it is 9, then the code should change to:


If VarType(chk1)=9 then
   chkbox2 =False
elseif chk1= True then
   chkbox2 =True
Else
   chkbox2 =False
End If

Use this version regardless. My last post needed some correction any way.

Mike

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



0
 
LVL 57
ID: 35175482

 Nice to see you around Mike :)

JimD.
0
 
LVL 44

Expert Comment

by:GRayL
ID: 35176737
Ditto :)
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 35178371
Thanks guys. I am here to learn some more from both of you.

Mike
0
 
LVL 1

Author Comment

by:Milewskp
ID: 35180309
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?
0
 
LVL 1

Accepted Solution

by:
Milewskp earned 0 total points
ID: 35185303
Hi all,
I've this and it seems to work (chk1 is greyed out when Null; chk2 is always white and checked or unchecked but always white):

chk1.Visible = False
chk2.Visible = True
chk2.Controlsource =Nz([Chk1],False)

Private Sub chk2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
      Me.chk1 = Not Nz(Me.chk2, False)
End sub
0
 
LVL 1

Author Comment

by:Milewskp
ID: 35185308
Thanks for your help folks, I'll go with my solution and give the assist to Mike.
0
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 35202134
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
0
 
LVL 1

Author Comment

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

Thanks again.
0
 
LVL 1

Author Closing Comment

by:Milewskp
ID: 35221317
.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question