Solved Navigation Form (1 Viewer)

Snowflake68

Registered User.
Local time
Today, 02:45
Joined
May 28, 2014
Messages
452
I have built an application using Access inbuilt tabbed navigation forms. I am not able to change the system not to use the built in nav forms now because the system is way too far along for that and very complex.

I have several tabs within my navigation form. The Home tab contains a subform called sfrmDS_Search which displays a list of reference numbers that when clicked take you to the Edit tab to edit the details of that record. It uses the 'BrowseTo' method to navigate to the Edit tab. The Edit tab has some On Load event code that runs when the tab is loaded. However when the Edit tab is first browsed to from the clicking on the ID from the Home first tab, the On Load event code runs twice for some unknown reason. I know this to be happening because I have put a simple pop up message at the start and end of the on load event code just to check my theory. However once the code has ran and the form is presented, if I then click the tab of the Edit tab (which reloads the form) then the code only runs the once which is what it should do. I am only clicking on the Edit tab of the current form just for testing purposes to see if the code run once or twice (the user wouldn't normally click on the Edit tab) but the code only runs the once which is what I what to achieve every time i navigate to the Edit tab from the Home tab.

I am not sure if the code is running twice initially because it is loading inside the container form of the navigation subform or because I am clicking a the Reference number from inside another DS subform but I would like to find a way of always running the code the once only so that it speeds up the loading of the form. There are numerous amounts of controls on the Edit tab and a vast amount of code that needs to run in order to check everything so it can take quite some time to run when the form loads, hence me only wanting it to run the once as it should do.

Is this an error on the Access software itself or am I missing something here.

I have attached a cut down version of the application leaving only the Home and Edit tab and some dummy data. If you click on one of the Reference numbers from the Home tab it will navigate to the Edit tab and you will get the test pop up messages for when the on load even code starts and another one for when it ends. But you will get them twice which confirms the code is running twice. But then once its has loaded click on the Edit tab to reload the form and you will only get the start and end messages the once which is what I want to achieve.

I hope someone can help figure out what is going on and whether there is a way of preventing the code from running twice. because loading the Edit tab is labour intensive due to the numerous amounts of controls and code that needs to run (I have removed all of this in the attached sample database).

Apologies for those that saw my earlier post for the same thing, I unfortunately deleted it by mistake.
 

Attachments

  • Navigation forms tab.accdb
    1.2 MB · Views: 216
Last edited:

isladogs

MVP / VIP
Local time
Today, 02:45
Joined
Jan 14, 2017
Messages
18,209
I haven't looked at your app and I read your comment about it being too late to move away from the built-in navigation forms.
This won't be what you want to hear but my advice is to do exactly that.

Navigation forms are a nightmare if you want to modify the basic form in any significant way.
For that reason, many experienced developers including myself never use them.

Even if you fix this issue there will be further issues in the future which will also be a pain to resolve.
It will probably be quicker to create your own forms to do the same job than the time needed to fix what you have.

Sorry if that all sounds negative.
Good luck with your project
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:45
Joined
May 7, 2009
Messages
19,228
check this one.
 

Attachments

  • Navigation forms tab.zip
    110.4 KB · Views: 282

Snowflake68

Registered User.
Local time
Today, 02:45
Joined
May 28, 2014
Messages
452
check this one.
OMG that is so simple. I cant believe it works. I did originally try to do the browse to in vba but couldnt get it to work. I will change all of my browse to macros for the other tabs to your vba method. Hopefully I can get everything to work OK now.
 

Snowflake68

Registered User.
Local time
Today, 02:45
Joined
May 28, 2014
Messages
452
I haven't looked at your app and I read your comment about it being too late to move away from the built-in navigation forms.
This won't be what you want to hear but my advice is to do exactly that.

Navigation forms are a nightmare if you want to modify the basic form in any significant way.
For that reason, many experienced developers including myself never use them.

Even if you fix this issue there will be further issues in the future which will also be a pain to resolve.
It will probably be quicker to create your own forms to do the same job than the time needed to fix what you have.

Sorry if that all sounds negative.
Good luck with your project
Thanks for your reply. I appreciate what you are saying about changing the application not to use the navigation forms but unfortunately the system is so big that I couldnt possible change it all now. The project is pretty much completed and its been 2 years in the making (on and off doing other projects too). I have managed to overcome all of the issues that I had due to using nav forms so I will stay with what I have now.

I am only reviewing bits to try and speed things up a little but hopefully I have now found the solution that 'arnelgp' has provided below.
 

AccessBlaster

Registered User.
Local time
Yesterday, 18:45
Joined
May 22, 2010
Messages
5,913
I have played around with navigation forms in the past, I have to say you have done a good job on your form.

All these tools are here to be utilized for different scenarios including macros. Good luck with your project.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 18:45
Joined
Oct 29, 2018
Messages
21,449
OMG that is so simple. I cant believe it works. I did originally try to do the browse to in vba but couldnt get it to work. I will change all of my browse to macros for the other tabs to your vba method. Hopefully I can get everything to work OK now.
Hi. I was going to do the same thing as @arnelgp did; but since he beat me to it, I decided to see what's wrong with your approach instead. Take a look at the attached now and let us know what you think. I just fixed your macro.
 

Attachments

  • Navigation forms tab (2).zip
    85.1 KB · Views: 205

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:45
Joined
May 7, 2009
Messages
19,228
if you haven't noticed, i removed the Filtering on qry_Section1.
instead i added another Textbox (txtQRef) to frmSection_1.
txtQRef value is derived from the MainForm, txtCurrentRecord textbox.
i use txtQRef as Link Master Fields of sub-subform sfrmDS_Section_1.
please see in design view of your form.
 

Snowflake68

Registered User.
Local time
Today, 02:45
Joined
May 28, 2014
Messages
452
Hi. I was going to do the same thing as @arnelgp did; but since he beat me to it, I decided to see what's wrong with your approach instead. Take a look at the attached now and let us know what you think. I just fixed your macro.
I see what you have done, thanks. I have change the system to use the vba browse to code that arnelgp provided but thanks for pointing out the error.
 

Snowflake68

Registered User.
Local time
Today, 02:45
Joined
May 28, 2014
Messages
452
if you haven't noticed, i removed the Filtering on qry_Section1.
instead i added another Textbox (txtQRef) to frmSection_1.
txtQRef value is derived from the MainForm, txtCurrentRecord textbox.
i use txtQRef as Link Master Fields of sub-subform sfrmDS_Section_1.
please see in design view of your form.
No I hadnt spotted that but I have it all working now thank you and its all down to you that the system runs so much faster now.
 

Users who are viewing this thread

Top Bottom