By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,997 Members | 2,841 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,997 IT Pros & Developers. It's quick & easy.

Inserting Subform by using the Command Button

P: 27
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
Sep 11 '08 #1
Share this Question
Share on Google+
3 Replies


Expert Mod 2.5K+
P: 2,545
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
Sep 11 '08 #2

P: 27
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. :(
Sep 11 '08 #3

Expert Mod 2.5K+
P: 2,545
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 Images
File Type: jpg ScreenHunter_57.jpg (16.1 KB, 115 views)
Sep 11 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.