473,978 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access Changes Primary Key to 0 when Foreign Table Record is added

13 New Member
Access 2003 - latest patches. Windows XP

Problem:
Table 1 is linked to Table2 by two fields. A Query is made to include all records from Table1 and only those from Table2 where the values match.
When entering data into one of the Table2 fields that does not have a related record to Table1, the Table1.Employee ID is being changed to zero (as opposed to propagating the Table1 keys into Table2 for the current record)

If I go into Table1 Table, expand the subdatasheet, and add a record into Table2 - it works fine - the keys are correctly propegated.

Design:
I have a two local Tables. One table is a data dump from a query against a SQL Server. The second table records additional information about the first one. It records the primary key information, plus the auxillary information. The design is set up in such a way that Table1 can be pruned and purged and the Auxillary information remains intact. This way we are not storing huge amounts of data in the local access file - only the linking information and the Auxillary data.

Sample DB Attached, or look below:


Implementation:

Table 1: EmployeeHours
EmployeeID - Long Integer
WorkDate - Date
HoursWorked - Single

Table 2: AuxInfo
EmployeeID - Long Integer
WorkDate - Date
Approved - Yes/No
Comments - Text(50)

Relationship:
(
Table1.Employee ID=Table2.Emplo yeeID(+)
AND
Table1.WorkDate =Table2.WorkDat e(+)
)



I must be doing something wrong.
Attached Files
File Type: zip test.zip (17.9 KB, 76 views)
Sep 15 '09 #1
4 2030
NeoPa
32,585 Recognized Expert Moderator MVP
To be honest I don't know for sure as I don't use this much.

Having said that, if I found myself in this position I would create something similar using the wizard and compare the options set. In a query (properly built as updatable etc) Access will populate the linked fields as soon as you add data into the Null side of the join. I certainly recommend testing this works with your query first before using the wizard to build the form.
Sep 15 '09 #2
NeoPa
32,585 Recognized Expert Moderator MVP
@NeoPa
Wow! That was obscure (and a little counter intuitive if I'm honest).

You need to clear the Default value of 0 in your definition of AuditNotes.Empl oyeeID. With that gone I found it worked, in the query at least. I had to look around quite a bit first before I sussed what was going on mind you.

Let us know how you get on.
Sep 15 '09 #3
Yesurbius
13 New Member
Thanks for the reply!

That _was_ the issue. I am not suprised it was something so basic - its usually those that are the hardest to find.

Normally I use AutoNumber fields - so I can see why this is suddenly popping up - I'm not using AutoNumber fields. When I created the test database - I did so from scratch .. so it must be a default value that access adds in there.

And it is very strange that it works when entered in a SubDataSheet via the main table.

Thanks again.

Thx again - will try it and let you know if that was the issue.
Sep 15 '09 #4
NeoPa
32,585 Recognized Expert Moderator MVP
No worries. Glad to be able to help :)
Sep 16 '09 #5

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

Similar topics

5
2148
by: dananrg | last post by:
I've created a small company database where the tables reside in a SQL Server database. I'm using Access 2000 forms for a front end. I've got a System DSN set-up to SQL Server and am using links within Access 2000 to get to the SQL Server tables. My forms worked fine until I made a few minor changes to the database schema on SQL Server (e.g. added a foreign key, or added a column). After that, all the links break - I click on a table...
6
2513
by: Andreas | last post by:
Hello list, what about uniqueness of inherited primary keys ? eg you have : create table objects ( id int4, date_created timestamp(0), primary key (id)
5
2243
by: Steve Strik | last post by:
My Problem: I have created a database here at work that is exhibiting some very strange behaviour. Essentially the database is structured in a manner where one table is a master record table (tbl_MainRegister) providing a unique identifier for documents and a means for identifying the docuement type. There are then 4 additional tables (tbl_Meetings, tbl_Documents, tbl_Project, tbl_Correspondence) which store the document details.
2
1803
by: DataB | last post by:
Hi everyone! I have a forms problem. Bakground: I have created a number of tables. Of these, I have a main parent table (Personal Details) and a number of other child tables (Tax file No., VISA card no.), etc...... All tables have a primary key of "Name", all child tables forming
1
1844
by: jhall | last post by:
At some point an index has been added to a table in my Access DB that does not allow duplicates. I can't see where I ever put an index on this field. But, when I tried to add 2nd records with a duplicate value in the 2nd field (not the primary key field) I get an error saying "The changes you requested to the table were unsuccessful because they would create duplicate values in the index, primary key or relationship."
4
6434
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database to look a and I am loosing tremendious amounts of time trying to organize it so that I could view it. Regards, Alexandre Brisebois
11
4527
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 AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their primary key to an "AutoNumber" type. If I'm right about this, I need some suggestions as to the...
4
2674
by: Don Do | last post by:
Help I built a form/subform/subsubform setup using the access forms wizard. I have a table1 = parent, table2 = child, table3 = (grandchild?). There will be multiple records in table2 that tie to table1, and multiple records in table 3 that tie to table2. Both on "1 to many" joins. Each of the forms are bound to the fields in the respective tables. The subform & subsubform are datasheet view. When I enter any data, I
1
1945
by: sjvandevoorde | last post by:
II am hoping someone out there will be able to give me some guidance, as I am about to give up. I have been working on this for some time and I think I have looked at it so much that I can't even think straight. I am working on a database to help track projects. There are three different types of projects/screens that I need. What I have so far: TABLE: Taskers (Screen/form 1) FIELDS: RMTaskerID – Autonumber/Primary Key CGTaskerNmbr -...
0
10359
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
10179
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11836
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...
0
11433
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11596
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
10922
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
10090
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
8467
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...
2
4748
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.