I can't get a checkbox to work with a yes/no field.

G

Guest

I am having some problems with a check box. I've added a field named "Floor"
, which is a yes/no field. tWhen I create the ehckbox I realize I must bind
it to a control source, which I do to the field named Orders!Floor. However,
when I click the checkbox on the form, I get the error message

"Control can't be edited. It's bound to the expression Orders!Floor."

I've tried unbinding the checkbox, and then using visual basic "on click"
event for that checkbox to read the value of the field, and then toggle the
display of the checkbox. But, then I get the error in visual basic, that the
variable "Floor" is not defined.

Note that if I show the box with the list of fields, the "floor" field is
not listed, even though it is a field in the table. I've tried exiting
Access and restarting to see if that would help Access remember what fields
are available.

What might I be doing wrong?

Joe Dunfee
 
J

Joan Wild

If floor is not listed in the field list, then probably your form isn't based on the table. More likely a query, or a SQL statement.

Open the form in design view, find the RecordSource property and hit the build button (...) to the right.

Edit the QBE grid to include the floor field. Now you can set the controlsource of the checkbox to 'floor'
 
G

Guest

Joe,

If a table is specified as a form's RecordSource, all fields will show up in
the Field List and the drop down list in the ControlSource property field. I
suspect your form's RecordSource is actually a query based on your table
rather than the table itself, and that you have not included Floor in the
query. Add the field to your query, save it, and it should be available to
you.

Hope that helps.
Sprinks
 
G

Guest

Thanks Joan and Sprinks for the replies.

I have not deliberately created any queries, and when I look at the Objects
Window to see if there are any queries and none are listed. When I select the
"..." next to the Control Source property for the check box, I am asked if I
want to create a query. If I say Yes, then in the query window, I can drag
the Floor field I want to the query.

What puzzles me is that,(before creating any queries, the list of fields
available for me to put on the form includes information from both tables.
[The two tables are called Customers, and Orders]

The wizzard I used to first create the form allowed me to select fields from
two different tables.

After selecting the form using the selection button at the intersection of
the rulers, the Record Source property currently says "SELECT Customer". The
drop down list shows the two tables, but I can only select one of them. If I
select the "..." then I am asked if I want to create a Query.

I tried again to create a new form using the wizzard. I was able to include
fields from both tables. When I looked at the control source for the Floor
field checkbox, it simply says "floor". I even tried just copying the
checkbox from this new form onto my original one.. but that doesn't work.

Perhaps, to add a new field from a table, you must create a query? I would
rather not create a query unless I need to.

Joe Dunfee
 
J

Joan Wild

Joe Dunfee said:
I have not deliberately created any queries, and when I look at the Objects
Window to see if there are any queries and none are listed. When I select the
"..." next to the Control Source property for the check box, I am asked if I
want to create a query. If I say Yes, then in the query window, I can drag
the Floor field I want to the query.

No, I said to select the "..." next to the Record Source property for the form. Add the Floor field to the record source.
After selecting the form using the selection button at the intersection of
the rulers, the Record Source property currently says "SELECT Customer". The
drop down list shows the two tables, but I can only select one of them. If I
select the "..." then I am asked if I want to create a Query.

OK, so click Yes and you can add the tables/fields you want. When done, don't click 'save', as that will save a query. Instead Close the window and when you are prompted to save the changes, click Yes. This will leave the record source with a SQL statement (SELECT Customer,....), but the Floor field added.

Once back in design view of the form, in the control source property for the check box, don't click on "...", instead click the dropdown and choose Floor.
 
G

Guest

Thanks for the tip.

I just found another way around these limitations. I created a new form
using the wizard, and added all fields from both tables. Then I deleted
everything on the new form, and finally copied everying off of the original
field onto the new one. However, I lost much of my VBA code in the transfer.
Your method preserves the original form along with its VBA code.

Joe Dunfee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top