Apparent MS Access bug related to hidden navigation pane (1 Viewer)

Bennet

New member
Local time
Today, 06:35
Joined
May 23, 2020
Messages
13
Just wondered if this is something people are aware of and what might be known about it.

I've noticed that you cannot manually trigger a DoCmd.SetParameter BEFORE you have viewed the navigation pane in a database.

To demonstrate this in its simplest form, if you:

1. Create a blank database
2. Set the option within "current database" to hide the navigation pane from the user by default.
3. Close and re-open the database.
4. When it re-opens, alt-F11 to get into the VBA window.
5. Try to set an arbitrary parameter in the immediate window - e.g DoCmd.SetParameter "test",1

You should get runtime error 2046 (something about SetParameter not being available).

It will keep returning this error until you go back to the main window and press F-11 to show the navigation pane. Then it doesn't happen anymore.

It's not just an issue directly in the immediate window. If you use the immediate window to manually call a subroutine that contains DoCmd.SetParameter before opening the navigation pane you get the same issue. However if you trigger it using a button on a form it seems to be ok.

Obviously this is easy to work around, I'm just wondering what else might be unavailable before the navigation pane has been opened. Is this a known issue? Is it any wider than I've discovered so far?

I can't possibly be the first person to have run into this.

(Alternatively maybe this is some weird bug specific to my personal PC...)
 

Attachments

  • Screenshot.jpg
    Screenshot.jpg
    137 KB · Views: 52

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:35
Joined
May 21, 2018
Messages
8,529
I do not think that is a bug per se. The Docmd and Runcommand methods are extremely "Focus" and menu item reliant. IMO limit there use unless no other means. Normally there is a more direct method. You often get these "Not available" errors when the corresponding method on the toolbar is greyed out. This is why I would always use a direct method method like the DAO object model.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 06:35
Joined
Sep 12, 2006
Messages
15,656
@Bennet

I expect not too many users have tried to do what you are describing. I have never used SetParameter to my recollection. I expect @MajP explanation that the object can't get the focus, so the action can't be completed is the issue.
 

Bennet

New member
Local time
Today, 06:35
Joined
May 23, 2020
Messages
13
Here's how I sometimes use set parameter to feed parameters into queries:

DoCmd.SetParameter "TheParameterName", 17 <- example value
DoCmd.OpenQuery "QryWhatever"

I'm vaguely aware there are other ways of doing this, but this one I've always found very straightforward to implement and very readily understandable at a glance.

Triggering off a routine that happens to make use of the above via the immediate window results in the error message I mentioned, unless the navigation pane has been opened first. As I mentioned, not a massive issue in itself, but I was wondering if it might be part of a more widely known bug or something.

Cheers.
 

isladogs

MVP / VIP
Local time
Today, 06:35
Joined
Jan 14, 2017
Messages
18,221
No, its not specific to your PC but I also don't see it as a bug.
To my knowledge, I've also never used SetParameter in this way in over 25 years working with Access
I'm sure there will be other actions that aren't possible when the nav pane is hidden
 

Mike Krailo

Well-known member
Local time
Today, 01:35
Joined
Mar 28, 2020
Messages
1,044
I like MajP's answer on this particular question. I've never had a need to use this technique before. I did learn something new today after looking up more info on it but I don't see the need to use it. Maybe you can enlighten us all.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:35
Joined
May 21, 2018
Messages
8,529
I would think to document all the cases and conditions under which certain Docmd methods are not available would be in the thousands or more cases/conditions. I doubt they would ever document that. There is sure a whole lot more things I would rather see documented. I personally would still suggest to avoid when possible not to go through the docmd (application methods) when you can code it more directly through the object model.
By that I mean things like:
me.recordset.findfirst vs docmd.gotorecord
me.somecontrol.setfocus vs docmd.gotocontrol
qdf.parameters("someParam") vs docmd.setparameter

I see people run into a lot of problems when they do not realize a lot of these methods are dependent on what object has focus and what state the application is in. The wrong object gets acted on or the "not available error."
 

isladogs

MVP / VIP
Local time
Today, 06:35
Joined
Jan 14, 2017
Messages
18,221
But why?!
The DoCmd.SetParameter method does not behave as documented? So, why shouldn't this be a bug?
I agree with MajP's comments.
Whenever part of the application interface is hidden, certain things will no longer work.
The documentation does not mention the navigation pane
 
Last edited:

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:35
Joined
Feb 28, 2001
Messages
27,186
Unfortunately, Access is not open-sourced so we cannot tell what isn't available when the Nav pane isn't open. However, from the discussion, whatever is needed by the SetParameter method isn't available in the circumstance described by the OP.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 01:35
Joined
May 21, 2018
Messages
8,529
Simple example. As you can see at this point in time the filter by selection is greyed out because my focus shifted to an unbound combo box from a bound control. If I try to run the command I get the not available now message. This case is not really a bug since the application is purposely designed to work that way.


notavailable.png
 

Users who are viewing this thread

Top Bottom