PDA

View Full Version : Solved: Can A results checkbox query in a table also display on a form?



wedd
10-24-2011, 05:17 AM
I have an expression that when the user ticks the checkbox or unticks it the words "Available" and "unavailable" are displayed in the table. What I would like to do is that the results based on the checkbox entry...i.e the actual words"available-when checked in the table) or unavailable-when unchecked in the table) also displays on a form. It just dispalys a checkbox on the form and it is impossible to indicate whether the reult is unavailable or not. Is it possible to display the results based on the checkbox query to also display the results also on a form based on when the user checks or unchecks the checkbox on the table? Is this possible, if so how can this be done? If this requires vba programming would you have an example as I am a novice.


Thanks for your contributions!:friends:

JimDantin
11-03-2011, 05:20 AM
I've read your question a few times and I'm afraid I'm still unsure of what you want.

Do you want "Available" to appear on the same form where the user checks the box? If so, why not simply have a label next to the checkbox "Available"? That is fairly universal meaning -- if the box is checked, then it is available.

If you want a text box to display "Available" or "Unavailable", then set the control source of the box to be something like:
=iif([availablecheckbox]=True,"Available","Unavailable")

[availablecheckbox] is the field name of your checkbox

If you want the text box to change when the user checks or unchecks the checkbox, then you need an event to trigger that either refreshes the entire form or you will need some VBA code that fills in the text box.

Hope this helps

wedd
11-14-2011, 09:32 AM
Thanks, Jim. I'm a beginner learning vba for access. Would you have an example of vba code that would be able to perform those actions in an event procedure? Thanks for your help.

JimDantin
11-14-2011, 09:51 AM
WHICH action are you asking about?

Again, I am unsure of what you are trying to accomplish. On my end, what you are asking sounds trivial. But I suspect I'm not understanding the problem correctly. "English" isn't quite the same on both sides of the pond!

wedd
11-14-2011, 10:03 AM
What I would like to happen on a form...is when a user clicks on the checkbox the word "AVAILABLE" appears in a blank textbox...and when the checkbox is unchecked the word "UNAVAILABLE" appears in the same textbox. Using vba can this be done, if so do you have an example of vba code that can do this? I hope that is clear. Thanks in advance.

JimDantin
11-14-2011, 01:56 PM
OK -- look at my example -- cerate a textbox and set the control source of the text box:
=iif([availablecheckbox]=True,"Available","Unavailable")

replace "[availablecheckbox]" with the actual checkbox field's name.

Then, set the "After Update" property of the checkbox to a new Event Procedure that contains nothing more than

Me.Form.Refresh

That should change the text box to either "Available" or "Unavailable" any time you click on the checkbox and it changes state.

wedd
11-15-2011, 06:47 AM
Great, it works! Thanks for your help! I've learn't something.