how to requery subform when closing another form?

siamandm
BronzeLounger
Posts: 1211
Joined: 01 May 2016, 09:58

how to requery subform when closing another form?

Post by siamandm »

Hello all
i have a mian form called frmMain, contains a sub form called frmSub
on the frmMain i have a button to open another form called frmAdd, on this form I have close button , when I click close button I would like to requery frmSub
using this code below:

Code: Select all

    Forms!frmMain!frmsub.Form.Requery
    DoCmd.Close acForm, "frmAdd"
  
I'm getting this error message : MS access can not find the file frmSub...

i have read on this and found this good article which I like to share too for other to get advantage from it.

http://access.mvps.org/access/forms/frm0031.htm

User avatar
HansV
Administrator
Posts: 78383
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: how to requery subform when closing another form?

Post by HansV »

Open frmMain in design view.
Click once on the subform to select it. Take care not to click in it again, for then you would select something on the subform; you want to avoid that at this moment.
Activate the Other tab of the Property Sheet.
The Name property (the first one on the Other tab) is the name of the subform as a control on the main form. This is the name to use in Forms!frmMain!nnn.Form.Requery. It is not necessarily the same as the name of the subform in the navigation pane.
Best wishes,
Hans

siamandm
BronzeLounger
Posts: 1211
Joined: 01 May 2016, 09:58

Re: how to requery subform when closing another form?

Post by siamandm »

you are the legend, thank you very much