473,511 Members | 14,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Master->Details record using Code (Autonumber)

2 New Member
I have similar but bit different issue that is

I have a table INVOICE when user enter data in invoice I have to insert record into Transactions (Master ) and Transaction_details (detail) both the tables have ID type autonumber i have a code that insert into record into Transaction table then when I try to insert record into transaction_details record I don't have the trasnsation ID which links these 2 tables. I am using MSaccess 2003. can any one help me in this.

Thanks ,
PP
Aug 4 '08 #1
1 2381
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi pkpanda, and Welcome to Bytes.

Autonumber fields can often be used as primary keys - but the ease with which Access offers them can lead to incorrect choices where such use is not appropriate at all. This is the case here in trying to use a separate autonumber field for your transaction_details table and applying that as if it has some relationship to your Transaction table - it doesn't. It can be used to uniquely identify the particular detail record involved, but not the one it is linked from. For that you need to understand that the key from the Transaction table has to be carried forward.

If a table is related one-many to another, the primary key of the one-side table is carried forward as a foreign key in the second table. Your transaction_details table should have not an autonumber for the foreign or secondary key from your Transactions table, but a numeric (long integer) field which will store the value of the autonumber field carried forward from the Transactions table.

If you change the data type of the transaction_details foreign key field to Numeric you can make use of a form-subform structure to set the parent-child links between the records shown in the forms. Using this approach Access will itself take care of carrying forward the autonumber value from your Transaction table to the corresponding Transaction_Details records. There are good examples of mainform/subform structures in the example Northwind database supplied with Access.

To avoid such PK/FK errors in future you may find it of help to review the following HowTo article on database normalisation and table structures. Of particular relevance to your situation is the customer-order-order_details example shown in the article.

-Stewart
Aug 10 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
373
by: Pure Heart | last post by:
hi the data menu option in visual basic 2005 "Configure Master-Details" dont activate when selecting bindingsource control so it works which which control -- Ammar S. Mitoori IT Head QIMCO...
10
3043
by: Mark | last post by:
I have a table about people containing 25 fields. The table contains the usual fields - first, last, address, city, state and zip. There is no primary key. These fields all have data with the...
2
1274
by: HS1 | last post by:
Hello all I followed the example in Visual Studio.net to create a master and detail relationship as following: two tables: Customers and Orders two DataGrid: GridOrders and GridDetails...
1
1627
by: SwatSoftwareDev | last post by:
Hi all, I have Master-Details-Details type of data i. e. every row of details table is attached with multiple rows of third table. What is the best approach (performance wise) to show this kind...
0
1210
by: Star | last post by:
Hi all, Newbie question here... I have followed this tutorial: http://www.ondotnet.com/pub/a/dotnet/2004/11/08/liberty.html?page=2 that explains how to display a Master-Details relation in...
1
2170
by: Sam | last post by:
Attached I am sending 2 URL's from MSFT ASP.net Quick Start Tutorial Web Site. 1) Run it URL: http://www.asp.net/QuickStart/aspnet/samples/data/GridViewMasterDetai... 2) View Source URL:...
1
1669
by: brian.newman | last post by:
I'm trying to link a gridview to another gridview in a Master-Details architecture. But the Details list isn't filtering like it is suppossed to. It will show all items on page load and it won't...
0
4736
by: ThePurpleCat | last post by:
Hi, I'm a newbie to ASP.NET programming but not to Visual Studio. I'm having trouble getting my Master-Details page to work. I have a page enabled GridView which is linked to a FormView control...
7
4529
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
0
1450
by: helveticus | last post by:
I have a master/details configuration that includes multiple user controls. The details page is configured to cache data via VaryByCustom. This works fine. One of the user controls contains an...
0
7252
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
1
791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.