Certain VBA will Not run when file is converted from ACCDB to ACCDE (1 Viewer)

yeasir01

Registered User.
Local time
Yesterday, 19:20
Joined
Mar 26, 2018
Messages
67
I recently converted my completed project from ACCDB to ACCDE, since then I noticed the following code will not run.

Code:
DoCmd.BrowseTo acBrowseToForm, "PrintSearchQuerySubForm", "MainSearchForm.Main_Subform"

The code is suppose to switch the navigation form from products tab to print list tab.

I've tried compliling all VBA codes, deleting unused sub routines, compact & repair, creating a new form & transfer VBA, adding this project to the trust list & enable all trust options.

When running the code it produces an error (in ACCDE). If the project is not converted then it runs without issue. Any Ideas what might be causing this?

The code sits behind the product profile form which then excutes the main form called "MainSearchForm"
 

Attachments

  • Error Screen With ACCDE File.png
    Error Screen With ACCDE File.png
    44.2 KB · Views: 88
  • Orginal With ACCDB File.png
    Orginal With ACCDB File.png
    16.7 KB · Views: 104
  • Product Profile.png
    Product Profile.png
    43.4 KB · Views: 88

Ranman256

Well-known member
Local time
Yesterday, 22:20
Joined
Apr 9, 2015
Messages
4,337
why not just use: docmd.openform ?
 

yeasir01

Registered User.
Local time
Yesterday, 19:20
Joined
Mar 26, 2018
Messages
67
why not just use: docmd.openform ?

The code posted does not open another form. it switches the navigation from products to print list.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 03:20
Joined
Jul 9, 2003
Messages
16,394
The code posted does not open another form. it switches the navigation from products to print list.

Well I don't really understand what you are saying.

But if your code is opening the form in edit mode, then it won't work in and mde/accde....

Sent from Barcelona!
 

Micron

AWF VIP
Local time
Yesterday, 22:20
Joined
Oct 20, 2018
Messages
3,478
If this is a navigation form as you said, then only one form is loaded at a time. If you switch tabs, one form closes and the other opens. You can't direct code to switch to another form because it isn't actually open. Nor can you reference anything from the prior form because it has been closed.
EDIT - forgot to address why this might occur in the accde and not the accdb. If you have compiled your code then it could be out of sync with what you see. The fix for this is to open the db using the decompile switch (Google it if unfamiliar), which will force a complete re-compile of your code. AFAIK, creating an accde does this automatically. If you have not compiled your code before creating the accde, then that is a mistake.
NOTE - it is wise to make a backup before opening a db with the decompile switch because it can recompile the code project into what you actually read, which isn't always a good thing.
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 19:20
Joined
Oct 29, 2018
Messages
21,582
Hi. The form doesn't look like a navigation form but more like a tab control. If it is a navigation form, are you saying the code is on the pop-up form? If so, can you show us the complete code? Is it a modal form?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:20
Joined
May 7, 2009
Messages
19,249
Code:
DoCmd.BrowseTo acBrowseToForm, "PrintSearchQuerySubForm", "MainSearchForm.[COLOR="Blue"]Main_Subform[/COLOR]"

is Main Subform the name of NavigationSubform?

did you SetFocus on the Navigation form before doing BrowseTo:
Code:
Forms("MainSearchForm").SetFocus
DoCmd.BrowseTo acBrowseToForm, "PrintSearchQuerySubForm", "MainSearchForm.Main_Subform"
 

yeasir01

Registered User.
Local time
Yesterday, 19:20
Joined
Mar 26, 2018
Messages
67
:eek: Thank you guys for all the input, but arnelgp was absolutely correct, the issue was that I didn't set the focus to the main form. Thank you very much!

Code:
Forms("MainSearchForm").SetFocus
DoCmd.BrowseTo acBrowseToForm, "PrintSearchQuerySubForm", "MainSearchForm.Main_Subform"
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:20
Joined
May 7, 2009
Messages
19,249
you're welcome!
 

Micron

AWF VIP
Local time
Yesterday, 22:20
Joined
Oct 20, 2018
Messages
3,478
it switches the navigation from products to print list.
I misunderstood. Thought you were trying to set focus to what you thought was an already open form.
 

Users who are viewing this thread

Top Bottom