Requery Subform Visual Basic

2019-08-09 08:35发布

I was just wondering if somebody could help with my subform not requering. My aim is that once a record is added in to my subform, I shouldn't have to push the 'Refresh All' button, I want it to refresh automatically. I have tried the following coding on After Insert of the Main Form, and on the Subform, but it hasn't worked. If anybody has any other ideas of how to do so apart from the way I tried, that would be great, thank you.

Creations is the name of the Form.

Private Sub Form_AfterUpdate()
    Form![Creations].Requery
End Sub

and

Private Sub Form_AfterUpdate
    DoCmd.Close acForm, "Creations", acSaveNo
    DoCmd.OpenForm "Creations
End Sub

1条回答
【Aperson】
2楼-- · 2019-08-09 09:19

If you are adding records via code, the requery should go in the procedure that adds the records. Most events are not triggered by programmatic changes to data.

For code running in the subform:

Me.Requery

The main form:

Me.Subformcontrolname.Form.Requery

Elsewhere

Forms!Mainformname.Subformcontrolname.Form.Requery
查看更多
登录 后发表回答