Add a subdatasheet
When two tables have one or more fields in common, you can embed the datasheet from one table in another. An embedded datasheet, which is called a subdatasheet, is useful when you want to view and edit related or joineddata in a table or query.
In this article
Introduction to subdatasheets
A subdatasheet is useful when you want to see the information from several data sources in a single datasheet view. For example, in the Northwind sample database, the Orders table has a one-to-many relationship with the Order Details table.
If the Order Details table is added as a subdatasheet in the Orders table, you can view and edit data such as the products included in a specific order (each row) by opening the subdatasheet for that Order.
If you add subdatasheets to your tables, limit the use of these subdatasheets to viewing, and not editing, important business data. If you want to edit data in a table, we recommend that you use forms to edit the data instead of subdatasheets, as data entry errors are more likely to occur in datasheet view if users are not careful to scroll to the correct cell. Also note that adding a subdatasheet to a large table can adversely affect the performance of the table. Microsoft Office Access automatically creates a subdatasheet when you create a table that matches one of the following criteria:
The table is in a one-to-one relationship. The table is the "one" side of a one-to-many relationship, where the table's SubdatasheetName property is set to Auto. A relationship is defined by matching the primary key and the foreign key fields in the related tables. You can also add a subdatasheet to any table, query, or form in a database. In Datasheet view, a form can display only one subdatasheet at a time.
TOP OF PAGE
To determine whether a table, query, or form already has a subdatasheet, open the object in Datasheet view. If an expand indicator (+ sign) is present, then the table, query, or form has a subdatasheet. When the subdatasheet is open, the indicator changes to a - sign. Subdatasheets can be nested in a main subdatasheet for up to eight levels.
To open the subdatasheet, click the plus sign next to the value for which you want to see the records. To close the subdatasheet, click the minus sign.
TIP To expand or collapse all the subdatasheets in an datasheet at the same time, on
the Home tab, in theRecords group, click More. Then select Subdatasheet, and click the option that you want. You can also remove or hide a subdatasheet. For information about how to remove a subdatasheet, see the articleRemove a subdatasheet.
TIP To hide a subdatasheet, open the table in Design View, and then on the Design tab, in
the Show/Hidegroup, click Property Sheet. Find the Subdatasheet Name line, change it to [None], and then save the change.
TOP OF PAGE
Add a subdatasheet
1. In Datasheet view, open the table or query where you want to add the subdatasheet. 2. On the Home tab, in the Records group, click More, point to Subdatasheet, and then click Subdatasheet. 3. In the Insert Subdatasheet dialog box, select the tab (Tables, Queries, or Both) that corresponds to the type of object that you want to insert as a subdatasheet. 4. In the Link Child Fields box, click the field that you want to use as the foreign key or matching field that will provide data for the subdatasheet. 5. In the Link Master Fields box, click the field that you want to use as the primary key or matching field for the main table or query, and then click OK.
For example, if you wanted to create a subdatasheet to view related orders for each Customer record in the Customer table, select the Orders table, in the Link Child Fields box, select Customer ID, and in the Link Master Fields box, select ID.
The values in the Link Child Fields and Link Master Fields boxes create a one-tomany join on the specified fields.
NOTE
6. To display the subdatasheet that you added to your table, query, or form, click the + sign.
NOTE The child (foreign key) field does not appear as a column of the subdatasheet. When you add
a new record in the subdatasheet, Access automatically inserts the primary key value of the selected base-table.
TOP OF PAGE
Applies to: Access 2007 See Also: Watch this: Create a form that contains a subdatasheet
Creating Multitable Forms in MS Access Creating Business Forms Using Word's Table Feature
Archived content. No warranty is made as to technical accuracy. Content may contain URLs that were valid when origina but now link to sites or pages that no longer exist.
By Susan Harkins Inside Microsoft Office 95 A Publication of The Cobb Group Published June 1997 Sometimes, you'll want to add data to two or more Access tables on the same form. Other times, you'll need to base an entry in one table on data that's stored in another table. In these situations, you'll want to set up and use a multitable form for data entry. For example, Figure A shows a multitable form included with Access' sample Northwind database.
Figure A: The sample Northwind database includes some multitable forms, such as this one.
Although it isn't readily apparent, this Customer Orders form includes information from three tables and is made up of three forms. The top form displays the customer's name, the middle form shows the orders made by that customer, and the bottom form shows the products included in the middle form's selected order. When you choose a different customer, different data appears in the lower two forms. When you choose a different record in the middle form, the bottom form displays data specific to that selected record. If you didn't use a multitable form, you'd have to display a different screen for each combination of company name, order, and order detail. For example, to display the same amount of information shown in Figure Aone customer, five orders, and three products you'd have to display 15 individual screens, each containing one item from each of the three tables. Fortunately, you don't have to go to this trouble, because Access lets you place forms for multiple tables on a single form. In any multitable Access form, you have a main form and one or more subforms. The main form displays data, as any form does, and serves as a container for the subform(s). The subform displays data that for the most part relates to one of the main form's fields. Although
the technique may seem difficult, creating a subform is a snap, as we'll show you in this article. Also, the possibilities are almost endless. Once you master this simple technique, you may find yourself redesigning all your forms.
On This Page
Creating the forms Creating a supplier subform Using the form and subform Creating a product subform Variations
and the subform more easily. We positioned the subform to the right of the product table's field controls, as shown in Figure C. We also deleted the supplier form's label.
Figure C: In Design view, position the main form's product data at the left and the subform's supplier data at the right.
To view the form at this point, click Form View () on the Form Design toolbar. As you can see in Figure D, the main form displays the first record in the Products table, while the subform displays the first record in the Suppliers table. If you browse the product records, you'll notice that the records in the subform don't change. That's because you haven't linked the two forms yet. This is your next step.
Figure D: The form displays information from both tables, but the data doesn't appear to be related
Since you want the record displayed in the subform to relate to the record displayed in the main form, you'll need to link the two forms. To do so, return to Design view by clicking Design View on the Form View toolbar. Right-click the supplier subform and choose Properties from the shortcut menu to open the subform's property sheet. To link the subform to the main form, you must link a duplicate fieldgenerally, you link a primary key field in the subform table. In this case, the most obvious link is the Supplier field. So click the property sheet's Data tab and enter the reference Supplier for both the Link Child Fields and the Link Master Fields properties, as we've done in Figure E. At this point, choose Save As/Export from the File menu, select the Within The Current Database As option, and specify the name F_Products&Suppliers. (We're giving the form and subform a new name because we're going to use our basic forms again later.)
Figure E: To link the forms, specify the Supplier field for both the Link Child Fields and Link Master Fields properties.
Top Of Page
Figure F: Once you link the two forms, Access will display the appropriate supplier data as you browse the product records.
Top Of Page
Now, click the Form View button's Form View option () on the Form Design toolbar. As you can see in Figure G, the subform's navigational scrollbarwhich displays the record indicator Record: 1 of 1shows that there's only one record for the first supplier, Cats Pajamas. That's because we purchased only one item from this particular supplier.
Figure G: The subform's record indicator tells us that we carry only one of the Cats Pajamas products.
Display the record for the second supplier, Dog Gone Best. When you do, Access displays its first product, Doggie Dandies, in the product subform. But notice that the navigational scrollbar in the subform displays Record: 1 of 2. This means the subform contains a second record. Click the subform's Next button (), and Access displays a second product for Dog Gone BestPuppy Love. If you continue in this manner, you'll find that Got Your Goat! supplies two of our products, Hare Care supplies three, and Kitty Palace supplies just one. Top Of Page
Variations
The technique we've shown you in this article barely scratches the surface of designing forms that contain subforms. For example, Access lets you make a subform invisible if its corresponding field in the main form is empty. In addition, you can design pop-up subforms that appear only when your cursor is on the related field in the main form. As the Northwind form shown in Figure A demonstrates, you can also link a subform to another subform that's linked to the main form. If you'd like to explore some other possibilities, open the forms in Access' sample databases in Design view and then look at the forms' and subforms' properties sheets. The Data and Event tabs are particularly useful for learning how to relate information between a form and its subforms. In addition to the Northwind database, which is stored in the Access\Samples directory, you can make Access create databases with sample data by choosing New Database from the File menu, clicking the Databases tab, and selecting a sample file. The Database Wizard will lead you through the rest of the process of creating the sample database. Susan Harkins is editor-in-chief of The Cobb Group's Inside Microsoft Access The article entitled "Creating Multitable Forms in Access" was originally published in Inside Microsoft Office 95, June 1997. Copyright 1997, The Cobb Group, 9420 Bunson Parkway, Louisville, KY 40220. All rights reserved. For subscription information, call the Cobb Group at 1-800-223-8720. We at Microsoft Corporation hope that the information in this work is valuable to you. Your use of the information contained in this work, however, is at your sole risk. All information in this work is provided "as is," without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement , and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Microsoft Corporation. Microsoft Corporation shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages. Top Of Page
Yes
No
Site Feedback
Products Services Text Market Book of Knowledge (articles & whitepapers) SQL Server 2005 Stored Procedure Programming in T-SQL and .NET, 3rd Ed. SQL Server 2000 Stored Procedure and XML Programming, 2nd Ed.
Linking tables
We can demonstrate this concept using tables which contain information about companies and cities. First, we will link the tables on the table level. The link will be implemented as a list box on the user interface level. Create following tables: CITY CityId CityName identification number of a city name of a city
COMPANY SQL Server 2000 Stored Procedure Programming e-Business News SQL Server News About Us Contact Us Join Us Links Search
2003 - Trigon Blue Inc. All rights reserved.
The CityId field links the tables. They are in a 1:n relationship, which means that: a company can be situated only in one city, but a city can have many companies. A record in the Company table has only one record in the table City, but a record in the City table can have more than one record in the Company table. It is possible to display a list box to select a city instead of a text box in which to enter a CityId into the Company table. Behind the scene Access will operate with the CityId field. An identifier, which corresponds to a selected city, will be stored in the CityId field of the Company table. Another result of such a link is that the user is prevented from entering a value which does not exist in the City table. You can accomplish this feat in following way: First, you create the City table in the standard way:
Note that the Data Type of the CityId field in this table is set to AutoNumber. When creating the Company table, you should include the CityId field as well. Usually, we would set the Data Type to Number (Long Integer). That type corresponds to AutoNumber. In this case we will select another one.
Since we want to use values from a lookup table, select the first option, then click Next. Select the City table as the source of values for your lookup column then click Next.
Select the fields that will appear in the lookup (list box).
Usually, you do not need to display the key column (CityId). Click Next to continue. Name the lookup column and click Finish.
If you open the table definition, you will notice that the CityId field's properties are set as follows:
table/query SQL query The property tells Microsoft Access which column values to use as the value of the control. If the control is bound to a field, the value in the column specified by the bound column property is stored in the field named in the Control Source property. specify the width of each column in a multiple-column list box.
Bound column
Column widths
It is also interesting to see how a lookup table is affected by linking. Open the City table and notice the '+' boxes along the left border. When you click on a '+' in one record, Access opens the section of the main table with the records associated with the selected lookup record.
Linking forms
Tables in Access can also be linked on the form level. We can do this on top of linked tables, but it isn't necessary. Forms can be linked even when the tables are not linked. In fact, that is what we recommend. It is better to link forms rather than tables. Create the City and Company tables as you would usually. Now we want to use forms to view and edit the content of these tables. We should have a list box to display cities on the form that displays Company information. Again, users will be prevented from adding a city for which there is not already a record in the City table. Create a form to show the Company table in following manner: In Design mode, put text box controls CompanyId and CompanyName and a combo box to show CityName from City table.
As soon as you create the combo, Access opens the Combo Box Wizard. Specify that the combo box will look up the values from a table. Click Next.
The wizard opens a window where you select a table to provide the values for your combo box. Click Next.
Select the fields that contain the values you want included in your combo box. Click Next.
The wizard displays a window with a preview of the combo box. Usually, you will not display the key column as a part of your combo. You can also adjust the width of the column(s). Click Next.
The wizard prompts you for the field that this column will be bound to. Select CityId and then click Next.
If you view the Properties of the combo box, you will notice that the wizard has changed the following properties: Specify what data appears in a control (CityId) table/query SQL query The property tells Microsoft Access which column values to use as the value of the control. If the control is bound to a field, the value in the column specified by the bound column property is stored in the field named in the Control Source property. width of each column in a multiplecolumn list box To hide first column set its width to zero (0";1").
Bound column
Column widths
When you activate the new form, you see the following:
When you add a new record, it is enough to type the first character of the name of the city (if the record is in table City), or to select CityName in combo box and it will be added.
specifies a number of columns displayed in a 2 list box or in the list box portion of a combo box specifies the width of each column in a 0";1" multiple-column combo box or list box. You can also use this property to hide one or more columns. specifies what data appears in a control which column values to use as the value of the control. If the control is bound to a field, the value in the column specified by the bound column property is stored in the field named in the Control Source property CityId 1
ColumnWidths
After everything is set, the combo box displays only CityName, but your program will use CityId behind the scenes.
Home | Products | Services | Book of Knowledge | e-Business News | SQL Server News About Us | Contact Us | Join Us | Links | Search
Instructions
1.
1
Select the "Create" tab and choose "Report Wizard" from the "Reports" group.
o o
2
Select the table or query you want to use for the invoice.
Sponsored Links
3
Highlight the field you want to add from "Available Fields" using the single arrow. To move all the fields, click the double-arrow. To insert fields from another table/query, repeat steps two and three. Then click "Next."
4
Select the order you want the fields to appear, then click the right arrow.
5
Click "Next" to choose a sort order or skip this step. To choose a sorting order, select the first field you want to sort from the drop-down. To switch to descending order, click "Ascending" and the button will change to "Descending." You can sort up to four fields.
6
Click "Next" when you are finished.
7
Pick a layout for the invoice, then click "Next."
8
Choose a style and click "Next."
9
Type in a report name for the invoice and select "Modify the report's design." Then click "Finish." You will be directed to "Design" view.
10
Double-click the button to the left of the "Detail" section on the invoice. The "Section: Detail" dialog box opens. o
11
Go to the "Force New Page" text field under the "Format" tab. Choose "After Section" from the drop-down list and close the dialog box.
12
Click the "Layout" or "Print Preview" view to display the invoice.
Read more: How to Create a Report in Microsoft Access 2007 With One Invoice Per Page | eHow.com http://www.ehow.com/how_6896344_create-2007-one-invoice-per.html#ixzz2PrxkcW2F
Keep track of your business transactions with a Microsoft Access database. Using tables and reports, you can log hours, wages and customer information, and display them with an invoice. Instead of manually creating a custom invoice each time you need to bill a client, Access can automatically
generate invoices that you can view, print or email. The report you create will contain all invoices, so you won't have to search for documents whenever you need to review previous invoices.
1.
Instructions
o
1
Create a "Customer" table that contains all of your customer or client information by clicking the "Table Design" button on the "Create" tab of the ribbon at the top of the page. The "Table Design" tool allows you to create a table from a blank template. Include fields for your customer's name, contact information and unique ID number.
2
Create an "Invoice" table that contains information regarding each business transaction. Add fields for location, cost and other necessary details. To assign a customer to each transaction, add a "Customer Name" field, select "Lookup Wizard" as a data type and link to the "Customer" table.
Sponsored Links
QuickBooks Online
QuickBooks Online is now in India. A Must Software for SMEs. Try Free! quickbooksonline.in
3
Select the customer's name field in the "Lookup Wizard" to display the names in the "Customer Name" field of your "Invoice" table. This step creates a relationship between the "Customer" and "Invoice" tables, and reduces data redundancy. Instead of typing in the customer's contact information for each business transaction, you store the information just once in the "Customer" table.
4
Create an "Invoice" report by selecting the "Report Wizard" button from the "Create" tab on the ribbon. Select all of your fields in the "Invoice" table and customer contact information from the "Customers" table to display on the report. Select "Modify the Report's Design" on the last screen of the "Report Wizard" to change the layout of the report.
5
Add a page header and footer, and include your company contact information, logo and invoice terms. Increase the size of the report's detail section to display only one transaction per page. Add subtotals and totals by placing calculated controls on your report and inputting an expression such as "=[BillableHours]*[Wage]."
6
Save your report and name it with a descriptive title. Switch to "Print Preview" view to review the content and layout of your report.
Sponsored Links
Read more: How to Use Microsoft Access for Invoicing | eHow.com http://www.ehow.com/how_8596642_use-microsoftaccess-invoicing.html#ixzz2Pry0s3IJ