Requery for Subform after Edit in Pop Up Form (1 Viewer)

Mari111

Registered User.
Local time
Yesterday, 23:49
Joined
Jan 31, 2018
Messages
37
Hello, I have a form with a subform. I have a function where I double click on a record in the subform and this opens a pop up editable form.

I want the subform to refresh after changes have been made on the pop up form.

At the moment I just have a 'save and close' button on the pop up form which returns to the form with the subform, but the subform isn't being refreshed with the new data. How do I get this to happen?

I have tried entering the code

Me!Subform.Requery but MS Access says it can't find the referenced form or that the form is closed (which is actually isn't).

Any answers?

Thanks
 

JHB

Have been here a while
Local time
Today, 08:49
Joined
Jun 17, 2012
Messages
7,732
Is you subform actually called "Subform", (else put in the correct name of the subform container control)?
 

Minty

AWF VIP
Local time
Today, 07:49
Joined
Jul 26, 2013
Messages
10,371
if your code to requery is in the pop up form close event, then you need to explicitly refer to the main forms sub form control.

So the syntax would be
Code:
	Forms!Mainform!ControlName
ControlName is the subform container name (Which confusingly may or may not be the same as you actual subform name depending on how you created it)

Other very useful form references here http://access.mvps.org/access/forms/frm0031.htm
Bookmark it !
 

Mari111

Registered User.
Local time
Yesterday, 23:49
Joined
Jan 31, 2018
Messages
37
Thanks JHB and Minty,

So now on my OnClose event of the pop up form I have put in the code:

Code:
Private Sub Form_Close()
Forms![FrmSearchHarvestList]![FrmSearchHarvestsSubform]
End Sub

However, Access doesn't like this because it is highlighting the code red.

FrmSearchHarvestList is the Main form the subform is located in.

FrmSearchHarvestsSubform is the subform in the main form.

FrmUpdateDetails is the name of the pop up form.

I have assumed the subform name is the same as the container name, how to I verify this?

Thanks
Mari
 

Minty

AWF VIP
Local time
Today, 07:49
Joined
Jul 26, 2013
Messages
10,371
You haven't specified what to do with the control, and I suspect your syntax is a little off.
I would also check the form is actually open.
Code:
If CurrentProject.AllForms("FrmSearchHarvestList").IsLoaded = True Then
      [Forms]![FrmSearchHarvestList].[Form]![FrmSearchHarvestsSubform].Requery
End If
 

JHB

Have been here a while
Local time
Today, 08:49
Joined
Jun 17, 2012
Messages
7,732
..
I have assumed the subform name is the same as the container name, how to I verify this?
Open the main form in design view, mark the subform container, look at the property "Name".
 

Mari111

Registered User.
Local time
Yesterday, 23:49
Joined
Jan 31, 2018
Messages
37
Thanks both,

Minty - I added your code and it worked :)
 

Users who are viewing this thread

Top Bottom