DoCmd.BrowseTo not available after DoCmd.OutputTo

choaspes

Registered User.
Local time
Today, 06:34
Joined
Mar 7, 2013
Messages
78
Hi All

Tearing my hair out with this one. My access db front end is based around a navigation form and on lots of the hosted subforms there are command buttons that trigger code that does "lots of stuff" then navigates to a different form. On many of those forms the "lots of stuff" includes using DoCmd.OutputTo to save reports to PDF, and have never encountered any problems. Today I'm working on one of the forms and have inserted a DoCmd.OutputTo part way through the "lots of stuff" and the code now throws "Error '2046': The command or action "BrowseTo" isn't available now" when at the end of the routine I try to navigate to a different form. The DoCmd.OutputTo prior to this works fine.

If I remove the DoCmd.OutputTo line I don't get the error, if I place the DoCmd.OutputTo line after the DoCmd.BrowseTo line I don't get the error (but the report no longer works because I've updated a bunch of records elsewhere in the "lots of stuff" before the DoCmd.BrowseTo). I have experimented with inserting an artificial delay in between the DoCmd.OutputTo and the DoCmd.BrowseTo but this has no effect. I believe I have tried all of the suggestions in this article except OP's bodge of closing then reopening the form:

vba - Access Navigation Control BrowseTo "The command or action 'BrowseTo' isn't available now. Error 2046 - Stack Overflow

I don't have this error message on any of my many other forms that host routines that are doing effectively the same thing. Please throw a drowning man a rope.
 
It seems to be this simple:

DoCmd.OutputTo "Whatever"
STUFF
DoCmd.BrowseTo "Wherever"
"Error '2046': The command or action "BrowseTo" isn't available now"

DoCmd.OutputTo "Whatever"
'STUFF
DoCmd.BrowseTo "Wherever"
"Error '2046': The command or action "BrowseTo" isn't available now"

'DoCmd.OutputTo "Whatever"
STUFF
DoCmd.BrowseTo "Wherever"
BrowseTo functions as expected

That one line is the difference between error and no error.
 
The answer is:

DoCmd.OutputTo "Whatever"
STUFF
Forms!NavigationForm.SetFocus
DoCmd.BrowseTo "Wherever"

Not seemingly necessary on any of my other forms in which I do exactly the same thing, but is necessary on this one!
 
Are your other forms all Navigation Form type?
 
If you want to pursue this, could you provide db for analysis?
 

Users who are viewing this thread

Back
Top Bottom