Click to See Complete Forum and Search --> : Delete record from table with Relationship


udi.p
February 14th, 2000, 08:12 AM
Hello.

I want to delete record from table (in access).
I use this line : data.recordset.delete
when i the program get to this line it make an error that say:
"can not delete record because it related to..(name of table)"
How can i delete this record ?
Thanks for help.

Cakkie
February 14th, 2000, 08:22 AM
When using relationships, you cannot delete a record with has a reation to another table, you must first delete the record in the table wich refers to it, eg:

We have two table, A contains the name, address and number of gender (eg: 0 = male, 1 = female)
They are linked with gender(A) and gNumber(B). Like this
[table A] [table B]
name |--gNumber
address | gName
gender ---|


When you try to remove like say '1 female' out of table B, you must be sure that there are NO records in table A wich have a gender 1. Only if there are no females in table A, you will be allowed to delete the record.
eg:
If table A contains following data

Tom Cannaerts - Somewhere in Belgium - 0
Pamela Anderson - Somewhere in US - 1

And Table B contains
0 - male
1 - female

you will not be able to delete the recode 1 - female, because in table A, we have Pamela, a female.
However, if there was no Pamela, nor any other females in table A, you can delete it.

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.