?
Solved

error when a foreign key of a record is deleted in its home record

Posted on 2003-03-31
4
Medium Priority
?
136 Views
Last Modified: 2010-05-01
I have set my access database to refrientual integrity. When i run my vb program and delete a record of a table and open a form of another table that has a foreign key of the deleted record the program gives an error. What will I do to prevent such errors?
0
Comment
Question by:willkee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 11

Expert Comment

by:supunr
ID: 8242438
it depends on what kind of error you get.  Do following checks before you do anything....

' recordset is closed
if (rsRecordset.state <> adStateopen) then
   exit sub
end if
' no records in the recordset.  handle it appropriately.
if (rsRecordset.Recordcount = 0) then
    exit sub
end if

' begining/end of recordset.  move to the first item
if (rsRecodset.BOF or rsRecordset.EOF) then
   rsRecodset.MoveFirst
end if

' Good Luck!
0
 
LVL 12

Accepted Solution

by:
jyokum earned 80 total points
ID: 8242758
In MS Access, did you create your relationships with "Cascasde Delete Related Records" checked? When it's checked, deleting a parent record will automatically delete all related record in child tables. If you take care of deleting the leftover data up front, you shouldn't have this problem.
0
 

Expert Comment

by:CleanupPing
ID: 8531239
Hi willkee,
This old question (QID 20569410) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9001715
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Award points to jyokum.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GrahamSkan
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question