Certain VBA will Not run when file is converted from ACCDB to ACCDE

yeasir01

Registered User.
Local time
Today, 16:53
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: 111
  • Orginal With ACCDB File.png
    Orginal With ACCDB File.png
    16.7 KB · Views: 125
  • Product Profile.png
    Product Profile.png
    43.4 KB · Views: 108
why not just use: docmd.openform ?

The code posted does not open another form. it switches the navigation from products to print list.
 
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!
 
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 by a moderator:
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?
 
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"
 
: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"
 
you're welcome!
 
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

Back
Top Bottom