If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
linking subforms
my application have customers and invoices. each customer can have 1
or more invoices. on my form i have a subform for customers and one subform for invoices. both subforms are in datasheet view. if i click on customer A in the customer subform i want the invoice subform to show only invoices for customer A and at the same time allow me to add invoices for customer A. what are the steps to accomplish this? also i want to be able to print a report such that customer A is listed together with all customer A's invoices followed by customer B and so on. how can this be accomplished? thanks for your help. |
#2
|
|||
|
|||
linking subforms
Assuming that the invoice table has contained in it a field that
contains the ID of the customer to wich the invoice belongs. 1) On the main form that contains both of these subforms, add a txtbox (txtCustID) make it visible property False. 2) in the OnCurrent event of the subform that is showing the customers add code forms![nameofmainform]!txtCustID = me.nameofcustomeridfield 3) Go to the second subform, and get the properties for the Form itself and on the data tab you will see "Link Child Fields" and "Link Master Fields" The wizard will NOT work because the main form is not linked to a table/query so instead in the "Link Child Fields" type [nameoffieldthatcontainsid of the customer master] in the "Link Master Fields" type txtCustID The above steps will handle automatically refreshing when you change records AND it will automatically load the customerid into the child field when you create a new record. (You will have to be sure to have "Allow Adds" set to yes on the child subform data tab. Ron |
Thread Tools | |
Display Modes | |
|
|