Full Version: Bound Checkbox To Pass Data To Sub
UtterAccess Forums > Microsoft® Access > Access Forms
deltabeans
Have searched the Forms Fourm but not found answer.
Split form with bound checkbox. User toggles checkbox using Form Click event. Form Afterupdate event pases Form RecordsetClone to Sub to make calculations and update labels on Form.
However, when recordset passed to the Sub is queried in loop about status of checkbox (I want to skip records with checkbox values of No, False, or 0; syntax is "If Not CheckboxName Then" ...), the recordset apparently has no unchecked boxes (that is, newly calculated labels don't appear on the form). If I close the form and then reopen it, appropriate calculated values are shown on the form. If I query the RecordsetClone's Updateable property, True is returned; so the Form AfterUpdate event has Recordset.Edit and Recordset.Update statements.
o what's wrong? Should I be using the Checkbox control OnClick event to do what I want? All help appreciated
theDBguy
Hi,
welcome2UA.gif
It might help understand your issue if you could post your code.
Just my 2 cents... 2cents.gif
Jeff B.
It sounds like you're trying to pass something from a main form to a subform. If so, why?
If you're using bound forms, and if you use Access main form/subform design as intended, Access handles the coordination between the main form and the subform.
More info, please...
deltabeans
It's not a form/subform situation. The Recordsource for the split form is a table that has a Yes/No field (as a Checkbox) whose name is Include".
heDBGuy: Relevant portions of the Forms code are appended in the CheckBoxCode.txt file.
Jeff B.: Form is bound but it's a split form not a Main/Subform.
Thanks for the help.
deltabeans
Solved the problem. Didn't pass the recordset to the Sub and showed calculated results in unbound text box rather than label caption.
ow, if i could just get all this to occur with the OnClick event of the CheckBox control on the form.
Jeff B.
Not sure from the description (congrats on a solution, by the way!), is there a chance that the ONLY thing the checkbox click does is display the calculated value(s)? If so, you could save yourself and your user one extra "click" by using code to do that.
theDBguy
Hi,
Congratulations on finding a solution on your own. Good luck with your project.
C
deltabeans
Jeff B., actually I was doing something truly stupid which was to use the CheckBox.AfterUpdate event to toggle the CheckBox. That is, I was using the statement Me.CheckBoxName= Not Me.CheckBoxName in the AfterUpdate. No wonder it wouldn't work. Solving that, when the user clicks the CheckBox everything happens as it should.
But let me ask a related question. While I was debugging the code I noted that a Me.Recordset.Edit command in the CheckBox_Click event, sends the code to the Form_AfterUpdate event. From there I can update the Label.Captions (which I have subsequently changed to unbound TextBoxes) on the form . Is that as it should be?
Again, thanks for your thought and help!
Jeff B.
I can't tell you if "that is as it should be"... What do you want to have happen?
Please describe the business issue that you're trying to solve by having the checkbox checked. I don't mean "what code should run?", but "why will users find it valuable (i.e., what will it help them accomplish)?"
deltabeans
The "Is this as it should be?" question was why Access sends control from the Click event to the Form_Afterupdate event if a "Me.Recordset.Edit" command is issued in the control click event. I am a hack, self-educated Access "programmer" and was just wondering why that might occur. Didn't seem logical to me (even though what happens is what I wanted to happen).
sing the OnClick event of the CheckBox does what I want for the user. The form allows the user to construct (by including/excluding table rows) a report of eligible medical expenses for a flexible spending account claim. The CheckBox is the means to include/exclude records.
Jeff B.
Thanks for the further clarification...
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.