Solved select one of checkbox

hatmak

Registered User.
Local time
Today, 05:24
Joined
Jan 17, 2015
Messages
121
hi

please need help to select one of option in form

home or work

as table designed

if I select home
work is false

and if select work home is false


thanks
 
Use an option group instead?
 
An option group would be the best solution. You can select checkboxes to display in an option group.

However, if you are dealing with checkboxes that operate on more than one field, then see my blog here the checkbox video shows you how you can achieve what you want:-

 
I need column for home and other for work
 
I NEED to be with VBA

TO DO IT IN MY DATABASE ( ATTCHED IS EXAMPLE )
 
Should be a single field not two fields. Choose either home or work as values not yes no
 
need VBA
as following

if I select home =true
work = false

If select work =true
home false

automatically
 
I suspect someone will join the thread shortly and write the code for the OP...
 
need VBA
as following

if I select home =true
work = false

If select work =true
home false

automatically
Have you tried to implement the solution offered by MajP in post #7
 
I would probably go with
Code:
Me.Control = NOT Me.OtherControl
in an event like AfterUpdate for just what you are asking?
 
I need column for home and other for work
No, you don't. As the others have said, you need ONE field not two. Your condition is MUTUALLY EXCLUSIVE. That means only one can be true at a time. Using an option group, use 1 for Home and 2 for Work and whenever you need to determine work or home look for 1 or 2 in the SINGLE field. Using two fields only makes the process more complicated plus it violates third normal form. At some point, you should probably learn about how to design a database schema so that is the topic - "database normalization". Lots of stuff here and on other sites.

I fixed the database. The option group is the no code solution. Don't make things more complicated than they have to be. The additional benefit of the option group is if you add a third location such as "Client Site", just add a third option to the option group and add code where you need only people logged as "Client Site" which should be value = 3. No table changes are required. And query changes would only be required in the case where you wanted to select ONLY Location = 3 which I've defined as "Client Site".

FYI, when working with an option group, you always reference the frame control and NEVER reference the controls inside. So to refer to this control on the form, use Me.fraLocation, NOT check25 and check27
 

Attachments

No, you don't. As the others have said, you need ONE field not two. Your condition is MUTUALLY EXCLUSIVE. That means only one can be true at a time. Using an option group, use 1 for Home and 2 for Work and whenever you need to determine work or home look for 1 or 2 in the SINGLE field. Using two fields only makes the process more complicated plus it violates third normal form. At some point, you should probably learn about how to design a database schema so that is the topic - "database normalization". Lots of stuff here and on other sites.

I fixed the database. The option group is the no code solution. Don't make things more complicated than they have to be. The additional benefit of the option group is if you add a third location such as "Client Site", just add a third option to the option group and add code where you need only people logged as "Client Site" which should be value = 3. No table changes are required. And query changes would only be required in the case where you wanted to select ONLY Location = 3 which I've defined as "Client Site".

FYI, when working with an option group, you always reference the frame control and NEVER reference the controls inside. So to refer to this control on the form, use Me.fraLocation, NOT check25 and check27
I have two fields in my database

I want if I chose the first option the other be false

like

please do it as

home and work

select home true ---- work is false

must select one of them

without use option group
 
I would probably go with
Code:
Me.Control = NOT Me.OtherControl
in an event like AfterUpdate for just what you are asking?
thanks

can I make the other field like

when I select home

work.enable=false
 
hatmak

OK. The attached db uses code to do as you requested.
BUT, as you have been advised, that this is NOT the best way to handle this data. I have to say that I'm not sure how much interest members will have in helping with any future issues that may arise from using this solution. Good luck with your project.
 

Attachments

Users who are viewing this thread

Back
Top Bottom