Choose a Subform based on selection in Main form

  • Thread starter Thread starter jlp
  • Start date Start date
J

jlp

Hello -
I have a parent table
tbl_Orders
Order_ID (pk)
OrderType (corresponds to different child tables)
OrderDate
RequestorName
QuickDescription

There are 5 different child tables that an order could
use depending on which type of order they are placing.
Basically, all of those tables are set up as follows, but
with 10-20 different fields in each table that correspond
to that order type.
tbl_OrderDetails_Type1
type1details_ID (PK)
Order_ID
Field1
Field2
Field3

What I need to do, is when the user enters the Order
information for the Parent table, I need the subform to
correspond to the "OrderType" that was selected.
So if they select "OrderType1", I need the subform
relating to tbl_OrderDetails_Type1 to show up, etc...

Any suggestions on how to go about this?
Thank you in advance!!
 
When you refer to a "Subform", there are actually 2 *distinct objects: the
SubformControl and the SourceObject od the SubformControl. Think of the
SubformControl as the empty rectangular container which allow you to set the
linking Fields between the main Form and the "Subform". The SourceObject is
actually the Form that is being used as the "Subform". If you look in the
Data tab of the Properties Window for the SubformControl, you see the
SourceObject Property.

You can use code in the (main) Form_Current Event and the AfterUpdate Event
of the Control that is bound to the Field OrderType to change the
SourceObject to the appropriate Form as required.

OTOH, I am not sure whether using 5 Child Tables is an appropriate
arrangement. However, you know your data best.
 
Back
Top