A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

linking subforms



 
 
Thread Tools Display Modes
  #1  
Old March 6th, 2008, 01:51 PM posted to microsoft.public.access.forms
[email protected]
external usenet poster
 
Posts: 8
Default 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  
Old March 6th, 2008, 04:11 PM posted to microsoft.public.access.forms
Ron2006
external usenet poster
 
Posts: 936
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.