Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OpenForm from subForm (A2k sp1)

    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

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: OpenForm from subForm (A2k sp1)

    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"?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm from subForm (A2k sp1)

    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

  4. #4
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: OpenForm from subForm (A2k sp1)

    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?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm from subForm (A2k sp1)

    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

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: OpenForm from subForm (A2k sp1)

    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.
    Charlotte

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm from subForm (A2k sp1)

    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

  8. #8
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: OpenForm from subForm (A2k sp1)

    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.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wetherby, Yorkshire, England
    Posts
    283
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: OpenForm from subForm (A2k sp1)

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •