By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Reflect Value of CheckBox in Field

P: 2
Hullo,

I'm only contracted in where I'm working and I'm trying to strip a lot of the VBA out so the in-house development can make changes easier.

I was wondering if I could set a control source on a checkbox and make the checkbox fill the control source depending on whether it is ticked or unticked?

For example if there was a field "WantSandwich" and a checkbox next to a label saying "Do you want a sandwich?" connected to it then ideally when the user clicked the checkbox it would set the "WantSandwich" field to "Yes" and if it were unticked it would set it to "No"

Regards,
Harry

P.S. I know this is a horrible way to do it and it should really be better laid out as a database, but this is all I have to work with
Dec 15 '11 #1
Share this Question
Share on Google+
4 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
I don't get what your trying to say.
For example if there was a checkbox for the field "WantSandwich" and a checkbox next to a label saying "Do you want a sandwich?" connected to it then ideally when the user clicked the tickbox it would set the "WantSandwich" field to "Yes" and if it were unticked it would set it to "No"
Are you using 2 checkboxes to track the same thing here?
Dec 15 '11 #2

P: 2
Ah, sorry. Explained it badly.

I meant to say:

"For example if there was a field "WantSandwich" and a checkbox next to a label saying "Do you want a sandwich?" connected to it then ideally when the user clicked the checkbox it would set the "WantSandwich" field to "Yes" and if it were unticked it would set it to "No""
Dec 15 '11 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
First off, lets try to get the definitions right, as it makes communication easier.

A field is what you find in your table, your query or your recordset. It is also sometimes referred to as columns, but the most correct term is field. Examples could be ID_Person, tx_FirstName, tx_SurName, tx_PhoneNumber.

A field cannot be next to a label. A control such as a textbox, a combobox, or a checkbox can be next to a label. A control can be unbound (Controlsource is empty) or bound (Controlsource lists the field to which it is bound) or calculated (The controlsource lists a calculation, such as "=[Price]*[Amount]")



The following is all about bound forms (Form has a recordsource) and bound controls (see above)
Now if you have a field WantSandwich, and the type of field is set to be a YES/NO field, with a default value of No (almost always remember default values in Yes/No fields), in your table, and you have pulled that field or the entire table into your form, and bound it to a checkbox by setting the checkboxes CONTROLSOURCE to be WantSandwich, then any click on that checkbox will change the value of the field WantSandwich in your table, for the currently selected record.

I hope that makes sense.
Dec 15 '11 #4

NeoPa
Expert Mod 15k+
P: 31,494
It certainly makes sense to me, and includes a lot of helpful explanations which are well worth taking note of.

In case it's not as easy for the OP (Harry) to understand I'll just add that all you need to do in your situation is to include the name of the field from your table ([WantSandwich]) in the ControlSource property of your CheckBox. This will ensure all changes to the CheckBox are reflected in the related field.

This is no different from what Smiley was saying. It simply expresses the same idea slightly differently.
Dec 15 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.