473,406 Members | 2,404 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,406 software developers and data experts.

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

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.EmployeeID 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.EmployeeID=Table2.EmployeeID(+)
AND
Table1.WorkDate=Table2.WorkDate(+)
)



I must be doing something wrong.
Attached Files
File Type: zip test.zip (17.9 KB, 75 views)
Sep 15 '09 #1
4 2006
NeoPa
32,556 Expert Mod 16PB
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,556 Expert Mod 16PB
@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.EmployeeID. 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
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,556 Expert Mod 16PB
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
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...
6
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
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...
2
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.,...
1
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...
4
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...
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...
4
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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
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
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,...

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.