linking subforms

F

fredloh

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

NetworkTrade

have your main form as Customers

add to it your subform of Invoices

(it won't be a datasheet style view)

same concept on the report side....

the subform/report wizard will guide you thru set up on both.....
 
R

Ron2006

For the first part:

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top