简体   繁体   中英

MsAccess: Subform requery from another subform not updating

I have a form called frmMain that has two subforms. frmUserRole and frmTraining.

The frmUserRole subform has a combobox the result of which I use to run in a query to generate training results in the frmTraining subform which has a single control called TrainingModule.

The frmTraining subform has a recordsource of the training query which as I mentioned before has a field referencing the combobox value.

Events

I have simple requery event connected to the on-change event in the combobox the logic being, if you change the value in the combobox, then the new value will automatically be used to update the query and populate the frmTraining subform with the new results.

The syntax I am using for the combobox on-change event is

[Forms]![frmMain]!frmTraining.Form.Requery

What is not happening

The subform is not updating with the new query results.

What is happening.

If I go to the frmTraining subform and press F5 the new values come through indicating that everything is operating except the actual requery.

If I put a msgbox on the on-change event it is triggered so I know the event fires.

I have not used the syntax you have used before. Here's the syntax I have previously used

Me![frmTraining].requery

And

forms!frmMain.form![FrmTraining].requery .

EDIT

I would set the training subform query criteria to forms!frmMain![frmUserRole]![combobox].column(0) on the related field.

I would then do the requery forms!frmMain.form!frmTraining.requery on the afterupdate of the frmUserRole subform combobox. I say afterUpdate because I believe there can be issues with onChange

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM