473,378 Members | 1,622 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,378 software developers and data experts.

Relationship getting deleted by itself!

This is a strange one--

I have an Access 2K database with a split front end/back end. There
are two tables in the back end - RFile and RLine. There is a one to
many relationship from Rfile.Rnumber to Rline.Rnumber. Originally I
went in with the Relationships window, drew the line, and clicked the
cascading updates and deletes. Everything was fine, for a couple of
years.

All of the sudden however, this relationship seems to delete itself.
It's quite unlikely that any user goes in and deletes the relationship.
In the last 3 months It has deleted itself 4 or 5 times. I go into
the back end, look at the child table (Rline) and I'll find 2 or 3 sets
of orphaned records where the parent record in Rfile was changed, and
the children in Rline weren't changed along with the parent thus
creating orphaned children. Of course, when I go to re-create the
relationship, it won't let me because of the orphaned records, so I
have to go and create the parent records again for these records, or
just delete them.

Help!

1) How could this relationship get deleted without someone actually
doing it.
and
2) I wrote a routine that automatically adds the records back in to
the parent table, but I am at a loss for the query that creates the one
to many relationship between the tables in the back end. If I had that
code, to create a one-to-many relationship in the back end, at least I
could have one of the users go in, click a button, and fix the database
when I'm not here.

-BrianDP

Mar 1 '06 #1
5 2367
Hi Brian

When you perform a Compact/Repair, one of the things Access does is rebuild
the indexes. If an error has occurred (e.g. if there is a duplicate in the
field that is supposed to be the primary key index), Access cannot restore
the index, so it deletes it (not the field, just the index.)

If there was a relationship that depended on this index (such as
relationship to a foreign key with enforced referential integrity), Access
can no longer enfoce the relationship without the key index, so it also
deletes the relationship.

Normally this is rare, though I also struck it yesterday on An Access 2000
machine running on Windows 2000. I don't know if the Win2000 bit is
significant, but Win2000 and Win2003 currently use a different version of
msjet40.dll than what Windows Xp does.

If this is happening regularly for you and the data is coming over a
network, it might suggest that one of your machines has a flakey network
card/connection, so the writes are not always completed and the index is
being corrupted.

IME, Access is very stable when the database objects are not being altered
(e.g. in an MDE), but does not cope well at all with unstable network
connections.

--
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.

"BrianDP" <bd****@gmail.com> wrote in message
news:11**********************@t39g2000cwt.googlegr oups.com...
This is a strange one--

I have an Access 2K database with a split front end/back end. There
are two tables in the back end - RFile and RLine. There is a one to
many relationship from Rfile.Rnumber to Rline.Rnumber. Originally I
went in with the Relationships window, drew the line, and clicked the
cascading updates and deletes. Everything was fine, for a couple of
years.

All of the sudden however, this relationship seems to delete itself.
It's quite unlikely that any user goes in and deletes the relationship.
In the last 3 months It has deleted itself 4 or 5 times. I go into
the back end, look at the child table (Rline) and I'll find 2 or 3 sets
of orphaned records where the parent record in Rfile was changed, and
the children in Rline weren't changed along with the parent thus
creating orphaned children. Of course, when I go to re-create the
relationship, it won't let me because of the orphaned records, so I
have to go and create the parent records again for these records, or
just delete them.

Help!

1) How could this relationship get deleted without someone actually
doing it.
and
2) I wrote a routine that automatically adds the records back in to
the parent table, but I am at a loss for the query that creates the one
to many relationship between the tables in the back end. If I had that
code, to create a one-to-many relationship in the back end, at least I
could have one of the users go in, click a button, and fix the database
when I'm not here.

-BrianDP

Mar 2 '06 #2
Compact and repair doesn't seem to have much to do with this problem.

One thing that you mentioned, which might be an issue, is fairly
recently (2 months?) about when the problems started, was when I moved
him from Win2K to WinXP with a new computer. Different versions of the
Jet hmm? Wonder what I can do about that. Is there an upgrade to fix
the latest jet? Or somehow reinstall the one he was using before this
problem started happening?

In any case, is it possible to create a relationship in that
relationship window with SQL code? If so, could you post how to post a
one to many relationship between rfile.rnmbr --> rline.rnmbr Rfile has
the one, and the rline has the many.

Many to Many thanks!

-Brian

Mar 2 '06 #3
Whether the repair was involved or not, the situation most likely represents
a corruption of the index and therefore loss of the relation. A genuine
solution must therfore identify what is causing the corruption and dealing
with, that rather writing code to create a self-closing gate after the horse
has bolted.

If you want to write it anyway, you will need to use DAO code to check for
the existence of the Index and the Relation with the correct Attributes and
Properties, and recreating them if missing or inadequate.

To get you started, the samples below show how to enumerate the Relations
for the database, and the Indexes for a table if that is what you want to
do. Again, though, I would consider this approach to be a genuine solution
to the problem.

Public Function ShowRel()
Dim db As DAO.Database
Dim rel As DAO.Relation
Dim fld As DAO.Field

Set db = CurrentDb()
For Each rel In db.Relations
Debug.Print rel.Name, rel.Table, rel.ForeignTable,
RelationAttributes(rel.Attributes)
For Each fld In rel.Fields
Debug.Print , fld.Name, fld.ForeignName
Next
Next

Set fld = Nothing
Set rel = Nothing
Set db = Nothing
End Function

Function ShowIndexes(strTable As String)
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim ind As DAO.Index
Dim fld As DAO.Field

Set db = CurrentDb()
Set tdf = db.TableDefs(strTable)
For Each ind In tdf.Indexes
Debug.Print ind.Name, IndexDescrip(ind)
Debug.Print " Field(s): ";
For Each fld In ind.Fields
Debug.Print fld.Name;
Next
Debug.Print
Debug.Print " " & IndexDescrip(ind)
Debug.Print
Next

Set ind = Nothing
Set tdf = Nothing
Set db = Nothing
End Function

--
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.

"BrianDP" <bd****@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Compact and repair doesn't seem to have much to do with this problem.

One thing that you mentioned, which might be an issue, is fairly
recently (2 months?) about when the problems started, was when I moved
him from Win2K to WinXP with a new computer. Different versions of the
Jet hmm? Wonder what I can do about that. Is there an upgrade to fix
the latest jet? Or somehow reinstall the one he was using before this
problem started happening?

In any case, is it possible to create a relationship in that
relationship window with SQL code? If so, could you post how to post a
one to many relationship between rfile.rnmbr --> rline.rnmbr Rfile has
the one, and the rline has the many.

Many to Many thanks!

-Brian

Mar 3 '06 #4
Could you verify, please, that you created the relationships in the
backend? You do mention the backend and it seems you have created the
relationships there but I did not find words where you stated
explicitly that you created the relationship in the backend, that is
with the backend db and its relationship window open, and not in the
front end, (preferably with the front end closed).
Creating a relationship in the front end could explain what you
describe. It's a common error. Another front end is opened; the
relationship is not available to that front end nor to the backend.
Regerential Integrity is compromised. Possibly it's too basic for you,
but we should rule out the obvious before we tackle the arcane.

Mar 3 '06 #5
Yes, I created the relationship in the back end, with the relationship
window open. I added the two tables, RFILE, and RLINE, and I drew a
line between the two. It seemed to know that it was supposed to be a
one-to-many relationship, and created it correctly. I cliked the boxes
to make referential integrity and cascading updates take place.

That's about it! I'm still thinking Allen may have hit on something
with a different version of the Jet. This database worked flawlessly
(well, okay, it worked very well, without this particular problem) for
years and years (6 years) before this all the sudden started happening.
The only change was the the client machine that constantly bangs away
at this database was changed from a 2000 to an Xp machine. It was also
changed from a 98 to a 2000 in this time as well, but that didn't cause
this problem. The Relationship Deletion problem as I've come to call
it started when I changed his computer out for a windows XP OS.

-Brian

Mar 3 '06 #6

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

Similar topics

7
by: francophone77 | last post by:
I deleted a relationship in the relationship view, but when I create a query that includes those two tables, the relationship reappears. When I go back to the relationship view there is NO...
8
by: Christopher Weaver | last post by:
I'm having the hardest time doing the simplest thing. I have a DataGrid bound to a table in a master detail DataRelation within a DataSet relTaskActivities = new DataRelation("TaskActivities",...
0
by: Steve Lewin-Berlin | last post by:
For some reason (and I wish I could say specifically when) studio.net keeps dis-associating my event handlers with their events. In a recent frsutrating example, my (C#) page_load routine wasn't...
3
by: Robert Ludig | last post by:
I am fairly new to SQL and I am currently trying to create a SQL table (using Microsoft SQL) that has a recursive relationship, let me try to explain: I have a piece of Data let's call it "Item"...
7
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on...
1
by: BuckBaxter | last post by:
Recently had trouble creating a one-to-many relationship between Customer table and Order table. After drag & dropping the field CustomerNo (key) in Customer table to CustomerNo (foreign) in Order...
3
by: Kush | last post by:
Hi. I was just wondering if someone could help me understand the relationship between the recv_hist_retention value and archive logs (and pruning of history file). My understanding is that the...
1
by: heatguru | last post by:
An Access 2000/2003 database has a form containing a memo field. Periodically the value of the memo field will show as #Deleted while the record itself is fine. The #Deleted value interferes with...
4
by: sriram | last post by:
Hello Friends, I am new to this group so big HIIIIIIII to all :) fine i have a serious doubt about session handling in PHP. After 20 min (default time) session getting expired, session values...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.