requery a sub form from anther form

kobiashi

Registered User.
Local time
Today, 13:33
Joined
May 11, 2018
Messages
258
hi all


so i have a form called form_plannedmaintenance_newentry, and a sub form on this form called, sub form_plannedmaintenance.

in the sub form, is a combo box called cboWorkType

one the form is a button, to open another form called form_workType

this form creates new entry selections in the combo box cboWorkType

now the question is, how do i requery the combo box or subform on form_plannedmaintenance_newentry, when i add a new entry on form_WorkType

i thought it would be

Code:
Forms!Form_PlannedMaintenance_NewEntry!SubForm_PlannedMaintenance.Form.Requery


but it didnt work
 
Have to reference the subform container control name. I always name container different from the form it holds, like ctrMaint. Then:

Code:
Forms!Form_PlannedMaintenance_NewEntry.ctrMaint.Requery
But if you want to requery a combobox:

Code:
Forms!From_PlannedMaintenance_NewEntry.ctrMaint.Form.cboWorkType.Requery
Are you opening the WorkType form from combobox NotInList Event? Post your code. Probably don't need to do the requery from the WorkType form. Consider:
Code:
DoCmd.OpenForm "form_WorkType", , , , , acDialog
Me.cboWorkType.Requery
acDialog suspends code excecution by the calling form until the called form closes.
 
Last edited:
thanks for the help everyone, but ive tried all of the suggestions, but non work, one thing i failed to mention, not sure if its a cause but the form_plannedmaintenance form is still open, would that cause an issue with the requery?
 
If by "form_plannedmaintenance" you mean the main form with the subform, then no. If it were closed, it would not be possible to requery the subform nor any combobox on it.

I revised my previous post for more info, possibly after you read it.

All suggestions are proven to work. Post your code or your database.

What does 'none work' mean - error message, wrong result, nothing happens?
 
ok so i open the form_workType from a button on form_plannedmaintnenance

code is to open "form_WorkType"

Private Sub btnAddWorkType_Click()
DoCmd.OpenForm "Form_WorkType_NewEntry", , , , , acDialog
End Sub


then i have on form_WorkType

Code:
Private Sub btnSave_Click()
    DoCmd.RunCommand acCmdSaveRecord   Forms!Form_PlannedMaintenance_NewEntry.CtrlPlannedMaint.Form.Requery
End Sub

i tried adding me.cboWorkType as per your suggestion but as it s on another form, it didnt fine it.

should i add Forms!Form_PlannedMaintenance_NewEntry!CtrlPlannedMaint.Form.Requery in stead?





in terms of it not working, nothing happens in terms of errors, but the data is not re queried
 
Last edited:
So did you consider the additional info in post 2?

Which form is "form_plannedmaintenance"? Your code references "Form_PlannedMaintenance_NewEntry" and "Subform_PlannedMaintenance".
 
so i have resolved this issues, thank you for the pointers, what i did was on click of the button

Code:
Private Sub btnAddWorkType_Click()
    DoCmd.OpenForm "Form_WorkType_NewEntry", , , , , acDialog
    Forms!Form_PlannedMaintenance_NewEntry!CtrlPlannedMaint.Form.cboWorkType.Requery
End Sub
 
Instead of running code to save record, close form_WorkType. That will commit the record to table.
 

Users who are viewing this thread

Back
Top Bottom