Full Version: Check box triggers another in subform
UtterAccess Forums > Microsoft® Access > Access Forms
hlpoindexter
I have a checkbox on a main form (deactivate) that when checked should do the following:
Insert today's date in a control on the main form (DeactivateDate)
trigger a TRUE result for check boxes in the subform (DeactivateItem)
I am using the following code:
Private Sub Deactivate_AfterUpdate()
Me![DeactivateDate] = Date
Forms![frmchangeorder]![DeactivateItem].Form![Deactivate] = True
End Sub
My main form is called frmchangeorder
My subform is called frmorderdetailschangeorder
Main form control check box is called deactivate
subform control check box(s) are called deactivateitem
The date works fine but i cannot get the subform check boxes to be referenced properly. I keep getting an error (can't find deactivateitem)
ace
Me.frmorderdetailschangeorder.Form gets you a reference to the
form in the subform control. From there just add .controlname for
the control you want to reference on that form.
hlpoindexter
compile error: data not found
Private Sub Deactivate_AfterUpdate()
Me![DeactivateDate] = Date
Me.frmorderdetailschangeorder.Form.DeactivateItem = True
End Sub
hlpoindexter
Private Sub Deactivate_AfterUpdate()
Me![DeactivateDate] = Date
Me!frmOrderDetailschangeorder.Form!DeactivateItem = True
End Sub
and with this, I get can't find 'deactivateitem'
ace
Based on the information you posted that path should work.
heck the object names, in particular the name of the subform
control which may or may not be the same as the form that is
contained by the subform control.
Is deactivateitem a checkbox or an option group?
Post the .mdb file for the quickest resolution of the problem.
hlpoindexter
i'm incredibly stupid. i had the wrong subform name. so the code below now works...but...i need all of the checkboxes in the subform to be checked 'true'.
The form is an order form that could contain a variety of items. when the checkbox in the main form is checked, i need all of the items (it will always vary) to be checked 'true' not just the first item:
Private Sub Deactivate_AfterUpdate()
Me![DeactivateDate] = Date
Me.sbfrmOrderDetails.Form.DeactivateItem = True
End Sub
ace
So the form with the checkboxes is a datasheet or continuous form?
hlpoindexter
yes, it is. continuous form.
ace
If you want to update every record in a continuous form the easiest
way is to execute and update query using the same criteria you
use in the recordsource of the subform.
On alternative to that is to loop through the form's recordsetclone
using DAO and the Update method of the recordset object. The help
file is a good place for examples of working with a recordset if you're
not familiar with that.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.