Inserting Subform by using the Command Button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MEGDZIA
    New Member
    • Apr 2008
    • 27

    Inserting Subform by using the Command Button

    Hi ,
    Could you please advise if there is a chance of adding a particular subform to main form by clicking the command button.
    Is there applicable VBA Code for that???

    Main Form: Quotation1
    Subform: Optional Quotation Subform

    Many thanks,
    Megdzia
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Hi Megdzia. It is really not practicable to do what you suggest, and I cannot really think of a situation where it might make sense to do so. It is more normal to be able to assign a different recordsource to the same subform if need be.

    What you can do, if you really need to have choice over the subform itself rather than its recordsource, is to design a main form with two subforms overlaid one on the other and use code to make one or the other visible to users under program control. It would achieve the same effect without trying to change the form design the way you suggest.

    -Stewart

    Comment

    • MEGDZIA
      New Member
      • Apr 2008
      • 27

      #3
      Thank you for your advice Stewart.
      The main form is used in my company as a Quotation Form.
      It has got one subform Quotation Subform to state Item, Description and Price. But some quotes need a optional table(in this case it would be second subform ). I cannot think of any other way of doing it. :(

      Comment

      • Stewart Ross
        Recognized Expert Moderator Specialist
        • Feb 2008
        • 2545

        #4
        It is quite possible to include a command button on your subform to open a pop-up form when needed, to fill in other details such as optional additional stuff.

        The design of the pop-up form would depend on the application, of course, but in effect instead of having two subforms in the one main form you pop up a third form on demand which is filtered by the relevant subform key fields so that it applies to the current record only.

        I use continuous view subforms so I can add command buttons to pop up subsidiary data (which you can't do in datasheet view).

        I attach a screenshot from an (old) application of mine which shows what I mean. Its a budget database which records totals for purchase orders issued. Each order can have many invoices attached, which are recorded through a pop-up form. Also, orders can have additional details, again entered through another pop-up form.

        -Stewart
        Attached Files

        Comment

        Working...