• OpenForm from subForm (A2k sp1)

    Author
    Topic
    #371958

    I have a small db of personal books with a tbl for authors and a tbl for books grouped by type. The main form is based on author with a subform for the books. i am sure I should be able to open the main form with a ‘where’ condition related to type on the subform but I can’t get the syntax right.
    Can anyone help.
    eg
    Docmd.Openform “MainForm” _ WhereCondition:= “subform.Form![choice] = “myInput”
    Thanks
    Peter

    Viewing 0 reply threads
    Author
    Replies
    • #592998

      your wrote:
      >>The main form is based on author with a subform for the books. i am sure I should be able to open the main form with a ‘where’ condition related to type on the subform <<

      Peter,

      I'm not sure I understand what you mean. The mainform must already be opened for you to see the subform, so what do mean by wanting to "open the main form"?

      • #593221

        Sorry folks – I should have explained better. Let me try again.
        Db opens to a form which is a menu of choices with command buttons. I choose a set of books by clicking a button and opening what I originally called the mainform, filtered to the appropriate list (F, P or O). So if I press “F” I get the main form with all the authors [Author] for “F” and the subform of all the book entries for those authors (to add, amend or print).
        So the code behind the button reads something like:
        DoCmd.OpenForm “MainForm”, wherecondition:=”[Choice]=’F'”
        At the moment [Choice] (F, P or O) is on the main form but I would like it to be in the sub form ( for good reasons which needn’t go in to). So the code could then read something like:
        DoCmd,OpenForm “MainForm”, wherecondition:=”subform.form![choice]=’F'” but that doesn’t work.
        I hope that’s clearer. Anyone help??
        Peter

        • #593255

          That helped some, but not much. Let’s assume the mainform contains your “F” authors. I’m then assuming your subform contains those books for the author that is currently displayed on the mainform. So what is it you are trying to do in the subform?

          • #593256

            Mark
            When I click the button on the menu form I want it to open the mainform by referencing a field in the mainform’s subform. Does that make sense?
            Peter

            • #593330

              No, it doesn’t. You can’t open a main form based on a value in its subform, because the values in the subform depend on the value in the main form. This question has been wrestled with a number of times in this forum, so you might want to do a lounge search to see what alternatives have been suggested in the past.

            • #593386

              Thanks Charlotte
              It’s not the end of the world I can work around it.
              Of course, what you say now makes perfect sense to me. I wonder why I didn’t see that in the first place? (You don’t need to answer that!!)
              Peter

            • #593389

              If this is a linked subform, then the values in the subform depend on the mainform. Not the other way around!

              Basically what you seem to be asking makes no sense. Perhaps you could explain it by giving a real example of what you want to do.

            • #593491

              Mark
              Thanks for your efforts. I realise the error of my ways now (see my response to Charlotte)
              Peter

    Viewing 0 reply threads
    Reply To: OpenForm from subForm (A2k sp1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: