473,663 Members | 2,877 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_det ails (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_det ails 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 2392
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_det ails 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_det ails 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_det ails 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_Det ails 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 Co. Tel : +9744831199 Mobile : +9745378400
10
3055
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 exception of a few records missing zip. A person may be in one to five records in the database. If a person is in multiple records, the other fields in the table in each record for that person may or may not contain data. I have two problems: 1. I...
2
1285
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 -------------- Dim myDataRelation As DataRelation
1
1631
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 of Master Details Data on web forms ? Thanks in advance. Regards, Swat
0
1218
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 your application. It looks simple, but for some reason, I cannot find the option
1
2177
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: http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples...
1
1676
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 remove any items when an item in the Masters list is selected. It shouldn't show anything until an item in the Master's list is selected and then only show the details which are associated with the selected item in the Masters list. I'm new to...
0
4741
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 through an objectdatasource. The paging on my GridView works fine except that when I change the page the FormView does not update. I tried setting the selectedindex to 0 in the GridView's PageIndexChanged event and manually binding the formview...
7
4535
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 records. Should I design a new form for this or can I somehow make this work in the same form. Thanks in advance, john
0
1454
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 image button. With caching turned on, the control remains "lame" since the control is only dynamically generated during the first access. My understanding is that page caching directive causes all page user controls to be implicitly cached as...
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8548
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8634
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2763
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.