473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Autonumber problem

Hi all,

Here's my situation:

I have 2 tables, let's call them TableA and TableB. TableA has a primary key
called AffNo, TableB's primary key (--> foreign key in TableA) is called ID,
and is Autonumber.
I want to do a form to input information for TableA, with a subform for
TableB where i can enter several records concerning TableA. This seems to
work, however, whenever i click on the 1st Field in the TableB subform, it
generates my Autonumber, but it also generates the record n+1, with empty
fields with exception of Autonumber, wich then has the same number in it as
the record n. This of course triggers a relationship problem because of the
uniqueness of TableB's primary key.

I would be grateful for any suggestions concerning this problem

Thank you,
Ralph Birden
Nov 12 '05 #1
3 1924
> I have 2 tables, let's call them TableA and TableB. TableA has a primary
key
called AffNo, TableB's primary key (--> foreign key in TableA) is called ID, and is Autonumber.


My understanding of this would be that: -.

If TableA has a one to many relationship with TableB then the primary key
from TableA (AffNo) should be a foreign key in TableB.
The problems you mention would then not exist,

Cheers,
Peter

Nov 12 '05 #2
Hi Peter,

That is right, but TableB has a one-to-many with TableA, that's why TableB
primary becomes foreign in TableA

Ralph Birden

"Peter Hoyle" <pe*********@ntlworld-NOT.com> wrote in message
news:OR0qc.12005$7S2.4595@newsfe1-win...
I have 2 tables, let's call them TableA and TableB. TableA has a primary

key
called AffNo, TableB's primary key (--> foreign key in TableA) is called

ID,
and is Autonumber.


My understanding of this would be that: -.

If TableA has a one to many relationship with TableB then the primary key
from TableA (AffNo) should be a foreign key in TableB.
The problems you mention would then not exist,

Cheers,
Peter

Nov 12 '05 #3
Ralph, I'm a bit confused here.

If you use the primary key of tableB as a foreign key to tableA, you cannot
have a one-to-many relationship between TableA and TableB. Since TableB.ID
is unqiue, you cannot have a 2nd record with the same number and therefore
you cannot have many related records in TableB.

Keep ID (the autonumber) as the primary key in TableB, but add another field
to be the foreign key.
Give it a Data Type of Number.
In the lower pane, leave the Field Size as Long Integer
Delete the zero from the Default Value property.
Set the Required property to Yes.
Save.
Now open the relationship window (Tools menu), and create a relationship
between this new field and TableA.AffNo.

Open your main form in design view.
Right-click the edge of the subform control, and choose Properties.
Beside the LinkChildFields property (Data tab of the Properties box), enter
the name of your new field.

Access will now fill in this value for you automatically whenever you enter
a new value in the subform (assuming the main form is not at a new record).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Ralph Birden" <ra**********@smc.etat.lu> wrote in message
news:40********@news.vo.lu...

Here's my situation:

I have 2 tables, let's call them TableA and TableB. TableA has a primary key called AffNo, TableB's primary key (--> foreign key in TableA) is called ID, and is Autonumber.
I want to do a form to input information for TableA, with a subform for
TableB where i can enter several records concerning TableA. This seems to
work, however, whenever i click on the 1st Field in the TableB subform, it
generates my Autonumber, but it also generates the record n+1, with empty
fields with exception of Autonumber, wich then has the same number in it as the record n. This of course triggers a relationship problem because of the uniqueness of TableB's primary key.

I would be grateful for any suggestions concerning this problem

Thank you,
Ralph Birden

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
35
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key...
26
by: jimfortune | last post by:
Sometimes I use Autonumber fields for ID fields. Furthermore, sometimes I use those same fields in orderdetail type tables. So it's important in that case that once an autonumber key value is...
4
by: Apple | last post by:
1. I want to create an autonumber, my requirement is : 2005/0001 (Year/autonumber), which year & autonumber no. both can auto run. 2. I had create a query by making relation to a table & query,...
11
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any...
2
by: Hiyella2 | last post by:
Hello, I have a problem with a table in my MS Access 2003 table. The primary key of this table is an autonumber field set to a Long Integer, Yes - no duplicates. The autonumber made it to 10252....
1
by: gtwannabe | last post by:
I'm having a problem with a form that uses AutoNumber as the primary key. I have an Abort button to delete the current record and close the form. If AutoNumber is assigned, the code executes a...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
1
by: OxfordConsult | last post by:
Hello, I have created a form that links with a table with the autonumber feature as its primary key. Whenever i create a new record in the form (using a command button ... i have disabled the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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...

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.