Solved Navigation form requery subform (1 Viewer)

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
Hi everyone,

I have been having a terrible time trying to get my forms to requery and refresh.

In summary

I have a Navigation form called main_nav_frm
Within this there is a tab called Summary
The Summary Tab is made up of a form called z_lab_summary_frm
The z_lab_summary_frm has 5 different subforms (which are various summaries of different lab work)
  • z_atlab_summary
  • z_call_lab_summary
  • z_due_this_week_summary
  • z_outstanding_summary
  • z_due_today_summary
In each of these 5 subforms, there is a button that opens a modal (each modal is unique to that form) that allows me to edit aspects of the data. After I edit the data, I click a save button in the modal which closes the modal and then the data is moves from one of the subforms to another through queries.

My problems is I cannot get the z_lab_summary_frm or main_nav_frm to refresh automatically. It works if i manually click the refresh button or if I move between the Summary tab and another tab.

I have tried me.requery from each of the 5 subforms after the open modal VBA command but that doesnt work.
I have tried Forms!main_nav_frm.NavigationSubform.Form.Requery on the close button of the modal as well as after the open modal button on the form.
I have tried a variety of combinations on different forms and pages to get it to requery/refresh and it still does not work.

Am I just an idiot and am not doing it properly or am I asking to much from the database?

Any help would be appreciated.

Thanks
 

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
Ok,

I think I figured a way to do it.
Not sure if its the cleanest way but

on the save button on the modal i placed this code

DoCmd.OpenForm "main_nav_frm"
DoCmd.BrowseTo acBrowseToForm, "z_lab_summary_frm", "main_nav_frm.NavigationSubForm"

there may be a better way to do it and i am still open to suggestions
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:25
Joined
Feb 28, 2001
Messages
27,148
From a sub-form, to requery that form is easy: Me.Requery

From a sub-form, to requery the parent form is still easy: Me.Parent.Requery

From a sub-form, to requery "sibling" forms gets trickier because you would have to do some kind of a loop through the parent form to find all sub-form controls. If so, you could do something like Me.Parent.sub-form-control.Form.Requery, which probably would be done best by making a separate subroutine. You could call it from any of the subs to search the parent's controls in a FOR EACH type of loop. Then for each sub-form you could trigger the Requery. And it wouldn't really hurt anything if you let the loop be the thing to requery even the sub-form from which that subroutine was called.

I edited this because the sentence got a little strung out.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:25
Joined
May 7, 2009
Messages
19,230
you only need to Requery the NavigationSubform:

[Forms]![main_nav_frm]![NavigationSubForm].[Form].Requery
 

Micron

AWF VIP
Local time
Today, 05:25
Joined
Oct 20, 2018
Messages
3,478
that apparently was tried?
I have tried Forms!main_nav_frm.NavigationSubform.Form.Requery
Your form design isn't clear to me:
or if I move between the Summary tab and another tab.
You are saying that your subforms are on pages of a tab control? Or by "tab" do you mean the navigation form tabs?
My experience with navigation forms is limited to assisting others who fancy them so if what you have works, might as well stick with it. AFAK, the browseto method is for switching between forms displayed by the navigation form. In that case, you're closing one form and opening another, which only adds to my confusion as to what you have.
 

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
you only need to Requery the NavigationSubform:

[Forms]![main_nav_frm]![NavigationSubForm].[Form].Requery
I tried this technique, but they forms would not refresh or requery.

The 5 subforms are in a form that is loaded from the prebuilt in access navigation tabs hence the browseto code that I am using at present that seems to work.

Like I said, I cannot figure out why the other options mentioned don't work so I am guessing it is the way the Access Navigation form system interacts with the subforms.

Thanks for everyone's comments. I am still trying a cleaner method and will post it if I can get it to work.
 

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
1592359593065.png

This is an example of the main_nav_frm in form view.
The summary tab is the first form in the main_nav_frm button
The 5 subforms (only 4 are visible) are set in z_lab_summary_frm which is what display when the summary button is pressed.

So when i click the tick button in "Return" in Due this W, it opens a modal and once specific data is modified in the modal, when the modal closes, the whole page refreshes and the line should disappear (based on the refresh/requery) This only works when I do the open.form and browseto command on the modal close.

I hope this adds more clarity to what is going on in the forms.
 

Micron

AWF VIP
Local time
Today, 05:25
Joined
Oct 20, 2018
Messages
3,478
Then if I understand what you have and are doing, you're not drilling down deep enough when you use the given reference. You need to requery the subform, yes? Then you need to drill down to the subform control, not just the navigation subform. If a subform control that holds one of these subforms was Child0 then it would likely be

main_nav_frm.navigationsubform.form.child0.form.requery <<don't use child0 unless that just happens to be your subform control name.

If that doesn't work and you want help to figure out how to get the subforms to requery, I think you need to post a db copy (zipped) with enough data and objects to work with in order to eliminate further guessing. BTW, when the modal form opens, I presume you have not switched the form you were on to some other form. If you did/do you can never requery this form. You will have to continue browsing to or otherwise opening that form back up.
 

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
Then if I understand what you have and are doing, you're not drilling down deep enough when you use the given reference. You need to requery the subform, yes? Then you need to drill down to the subform control, not just the navigation subform. If a subform control that holds one of these subforms was Child0 then it would likely be

main_nav_frm.navigationsubform.form.child0.form.requery <<don't use child0 unless that just happens to be your subform control name.

If that doesn't work and you want help to figure out how to get the subforms to requery, I think you need to post a db copy (zipped) with enough data and objects to work with in order to eliminate further guessing. BTW, when the modal form opens, I presume you have not switched the form you were on to some other form. If you did/do you can never requery this form. You will have to continue browsing to or otherwise opening that form back up.

Thanks...that makes sense. I am still learning VBA syntax and could not find an example of the syntax that essentially drilled down so far.

I'll give that a go later today and report back as to how it worked

I am assuming that the VBA code from the modal save and close button would be
Code:
DoCmd.RunCommand acCmdSaveRecord

 DoCmd.Close
main_nav_frm.navigationsubform.form.z_lab_summary.form.requery
 

Micron

AWF VIP
Local time
Today, 05:25
Joined
Oct 20, 2018
Messages
3,478
I don't know if you'd find it - I just coughed it up by applying the principles. Take the syntax you were given that didn't work for example. If you understand the hierarchy of the objects in the normal case, then as long as you understand why it works, you just extrapolate and repeat the relevant parts. If you had nested subforms 4 levels deep, I'd just keep adding to it: Child1.Form.Child2.Form.Child3.Form and so on, so I will be interested to know if I've figured it out, for sure. If not, then like I mentioned, I need a db to see exactly what structure you have.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:25
Joined
May 7, 2009
Messages
19,230
you don't need a db, you can try it yourself using dummy data.

whether you are Using 1 level or 2 level navigation buttons,
all Forms/Reports are hosted by a Single navigationSubform.
Code:
DoCmd.RunCommand acCmdSaveRecord

DoCmd.Close
Forms!Main_nav_frm!Navigationsubform.Requery

hat apparently was tried?
then for sure the OP get error because it's not the
proper syntax.
 
Last edited:

Micron

AWF VIP
Local time
Today, 05:25
Joined
Oct 20, 2018
Messages
3,478
then for sure the OP get error because it's not the
proper syntax.
That appears to be true, given that you have changed your suggestion from

[Forms]![main_nav_frm]![NavigationSubForm].[Form].Requery
to
Forms!Main_nav_frm!Navigationsubform.Requery
which does seem to work, but then so does my syntax. Yours is simpler when it's correct.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:25
Joined
May 7, 2009
Messages
19,230
which of your syntax is correct?
it is better to Correct my Air code, rather than:

Child1.Form.Child2.Form.Child3.Form

is that normal!?@#
 

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
Code:
DoCmd.RunCommand acCmdSaveRecord

DoCmd.Close
main_nav_frm.navigationsubform.form.z_lab_summary.form.requery

I tried it but i get an error saying object required. so I may not be drilling down far enough or I have drilled down too far
 

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
I'll try some of the other suggestions tonight.

Thanks for everyone's input so far.

Ive learnt a lot so far about form syntax
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:25
Joined
May 7, 2009
Messages
19,230
try post #11, that is the Correct syntax.
only main_nav_frm and NavigationSubForm is involved.
don't include other Forms as you did in post #14.
 

crazy_ivan_1

New member
Local time
Today, 19:25
Joined
Jun 7, 2020
Messages
23
thanks all

i tried


Code:
DoCmd.RunCommand acCmdSaveRecord

DoCmd.Close
Forms!Main_nav_frm!Navigationsubform.Requery

still couldnt get it to work. I maybe the way I have done something in the setting up of the DB. I'll keep tinkering, but for now ill use the browse to function.
 

Ashisht76

Member
Local time
Today, 14:55
Joined
Jan 31, 2022
Messages
44
you only need to Requery the NavigationSubform:

[Forms]![main_nav_frm]![NavigationSubForm].[Form].Requery
hi. i will be highly obliged if you could give code for requery a combobox on a form that is in navigation form.
 

Users who are viewing this thread

Top Bottom