Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2003-03-31
4
Medium Priority
?
140 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
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 77

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, 16 hours left to enroll

564 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