Share via

DoCmd.BrowseTo error

Anonymous
2013-02-22T18:59:36+00:00

I am tearing my hair out. In one application my code executes perfectly (=opens the subform "Payee Form"). In another application the same commend gives me an error “… not in correct form…” Furthermore the MS sample code is of NO help.

My CODE:

 DoCmd.BrowseTo acBrowseToForm, "Payee Form", "Start-up.NavigationSubform"

MS sample code:

DoCmd.BrowseTo ObjectType:=acBrowseToForm, _ObjectName:="EventDS", PathToSubformControl:="Main.NavigationSubform"

Help please!

Ed

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2013-02-25T04:46:21+00:00

    The basic issue is you have some code that works just fine in one application. That same code does not work in a new application.

    And you posted two different syntax examples.

    I assume you are asking why the help has such a DIFFERENT code sample then what you have (or at least I assume you are doing as such, else why post two VERY different examples of code?)

    So the reason why the help file has such a DIFFERENT syntax from what you posted is there are two ways of using a function (as I explained above).

    So my explain here is WHY YOUR example looks SO VERY different then the help example. And if you are not confused by the help example then why are you quoting and posting that example that you note is not working for you and of no help then?

    My simple suggest is really just that, a simple suggestion.

    So I am stating I think it best you continue using the same code and same syntax as the code that you stated works so well in your first case.

    Now that we cleared up why your two posted example are so different to the reading public here (after all, people are here to learn), then the next issue remains:

    Your first example code should work in the other application. We just don't know why and that of course is your basic question.

    The ONLY reason I can think of why this code does not work in the new application is that your form name(s) are different, or as noted there is some different nesting of the forms due to (possible) use of a navigation form.

    In other words, since you have in the past had success with the particular format and particular syntax you posted, then I think you should continue to use that same base format and tweak that code to work in the new application. (don’t use the help example format you posted since as noted it uses a DIFFERENT format for the function parameters).

    In other words, I am in effect agreeing with you that it makes LITTLE sense to adopt the help file syntax (that YOU quoted) and that YOU yourself claim is confusing and not helping you.

    So I 100% agree – it makes ZERO sense to use the DIFFERENT syntax and DIFFERENT format THAT YOU outlined and posted from the help file.

    In other words, CONTINUE using your existing syntax as opposed to the help file syntax which we BOTH agree is not only confusing, but is in fact not required here!

    The simple and basic advice here is to continue using, and stick to the syntax and format that you had the most success with in the past.

    As noted, since your given first example code does not work in the second example, then something in regards to the form name must be different. Perhaps there is some other issue we simple have not yet considered here such as nesting or navigation forms. The code should work, but since it does not then something must be different in the second application.

    So the basic lesson and first advice from the "get go" is I much think it is best to stick to using your first syntax that you at least had some success in the past.

    It is possible I am not grasping why you posted two very different syntax here if you did not want a explain as to why the two syntaxes are so different? Perhaps you DO want to adopt the second syntax format you posted, but you have freely admitted that such a syntax from the help is of little use to you. And my point is you don't need to adopt that syntax to fix your problem anyway.

    If the form names are exactly the same in both applications, and you double checked that the syntax of your code is also 100% the same (no type-o's), then additional trouble shooting will be required.

    Albert D. Kallal (Access MVP)

    Edmonton, Alberta Canada

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2013-02-24T18:20:41+00:00

    Albert,

    I have NO idea of what you are saying.

    I hope that some one else will be able to shed some light on my delema.

    Ed

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2013-02-24T01:09:47+00:00

    Your syntax looks correct. The reason why the other example is different, there are TWO WAYS to pass parameters to functions.

    #1 choice:

    You pass the parameters based on their position.

    So for a message box with a title, you can use this:

    MsgBox "hello", , "box title"

    In the above, the "prompt part" = "hello"

    In the above the "title part" = "box title"

    However, in all functions you do NOT necessary have to pass parameters based on position. You can use what is called named parameters.

    The advantage of "named" parameters is order or position DOES NOT matter. So if I decide to use named parameters for the msgBox command, then I can use this:

    #2 choice

    MsgBox Title:="box title", prompt:="hello"

    Or I can use this:

    MsgBox prompt:="hello",Title:="box title"

    Note how the ORDER or POSITION of the parameters DOES NOT matter. However, ALL THREE of the above are functional THE SAME command.

    So the reason why you see different syntax is because there are TWO WAYS to use functions.

    In your first example you state your code works.

    If moving the code to a DIFFERENT application does not work?

    Then the form names used in the second application MUST be different, or you are not sharing some other unknown details.

    So at the end of the day, since your first example (that does NOT use named parameters) works fine, then it should work just fine in the other application. The issue is NOT different syntax but ONLY that your new and other and different application clearly must have different names for the forms involved.

    Your syntax looks fine – the issue is different form names in the "other" application.

    Albert D. Kallal (Access MVP)

    Edmonton, Alberta Canada

    Was this answer helpful?

    0 comments No comments