Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting error when attempting to delete record from main form

Status
Not open for further replies.

normat

Technical User
Mar 13, 2001
3
US
I am very new to Access. I have created a very simple form and subform just to learn how to use VBA. I have created two test databases. One called Employee and the other called Employee Sales. I link the two databases using the empid field. I set up a relationship using the empid for both databases. They have a one to many relationship. I enforce referential integrity. Check "cascade update related fields" and "cascade delete related fields."

I created my main form and a subform. I can add records and update records just fine, however when I try to delete a record from the main form (cursor is on main form's control) I get the following error:

The table "Employee Sales" is already opened exclusively
by another user, or it is already opened through the user
interface and cannot be manipulated programmatically.


Any ideas as to what I am doing wrong?
 
normat:
Please don't get me wrong, but First you don't have two databases you have two Forms.
Second, the fact that you build a relationship and enforce the referential integrity does not means that you may modify or delete any row from any table in any way. To the contrary. You had implemented the more efficient way to handle data (Forbid to do what you're trying to do).
What you said lead me to think that you want to delete rows in the many side. something that can't be done since you enforce the referential integrity.
So, if you want to delte rows you have to do it from the Main table and not inverse. Furthermore if you want to delete rows in the many table you will need to:
1. Delete it in the main table or
2. Remove the relationship between the tables

Here is a concept in plain english of what referential integrity means

A feature provided by relational database management systems (RDBMS's) that prevents users or applications from entering inconsistent data. Most RDBMS's have various referential integrity rules that you can apply when you create a relationship between two tables.

For example, suppose Table B has a foreign key that points to a field in Table A. Referential integrity would prevent you from adding a record to Table B that cannot be linked to Table A. In addition, the referential integrity rules might also specify that whenever you delete a record from Table A, any records in Table B that are linked to the deleted record will also be deleted. This is called cascading delete. Finally, the referential integrity rules could specify that whenever you modify the value of a linked field in Table A, all records in Table B that are linked to it will also be modified accordingly. This is called cascading update.

Copied as is from this Site:


Good luck

Estuardo


Note:
Please if i'm doing something illegal by copying this text please let me know.
 
Thanks for the reply, but it still doesn't help me. I know how the update and delete option work. I am pressing the delete key on my main form (which uses my primary table) not my subform (Employee Sales).

I not only want the users to be able to see the employee information from the primary table on my form - and the sales information for that employee; hence the subform -but I also want them to be able to delete the primary table information, which inturn should delete the sales information for that employee - since I have cascade delete checked.

I hope I explained myself a little better. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top