goldstar19821982
03-04-2008, 09:54 AM
Hello All,
Just a quick query, i have two tables, one contains the list of items in each hire and the other table the client details etc with regards to that order.
I have a transaction list form where all the transactions that are placed will appear.
If the transaction for a certain order is deleted i want the details for that hire to be deleted from both tables.
This is what i have been trying but it does not like it.
CurrentDb.Execute ("Delete * from tblitemhire, tblhire Where tblitemhire.itemno & tblhire.itemno =" & Forms!frmtransactionlist!txtitemno)
ajetrumpet
03-04-2008, 10:26 AM
Maybe you could just drop this method and create a Delete Query??
The deletion should grid rid of all of the related records to that main record if you have specified the "cascading delete" option as a "yes" in the relationship of the tables. Would this method work, I wonder?
goldstar19821982
03-04-2008, 11:27 AM
This might sound like a dumb question.
How do i connect a composite key to another table and allow the cascade deletion to be ticked.
it says
No unique reference found for the reference field in the primary table
Im trying to connect one item of the composite key to the matching field within the other table?
goldstar19821982
03-04-2008, 12:09 PM
Im trying it this way
CurrentDb.Execute ("Delete * from tblitemhire Where tblitemhire.itemno=" & Forms!frmtransactionlist!txtitemno)
CurrentDb.Execute ("Delete * from tblhire Where tblhire.itemno=" & Forms!frmtransactionlist!txtitemno)
Data Mismatch error appears highlighting the second of the two.
Would you know why this wouldnt work
ajetrumpet
03-04-2008, 12:29 PM
I don't think that is relevant GoldStar.
I can tell you that the way you have written the code would not comply with a field formatted as text, because (as far as I know), a value considered to be of text data type, when referencing a form control, needs to be enclosed in quotes, like this:("Delete * from tblhire Where tblhire.itemno = Forms!frmtransactionlist!txtitemno")
Aren't we veering off topic here though?
goldstar19821982
03-04-2008, 12:44 PM
Yeah your right, but as it wont allow me to produce a relationship between the two tables as mentioned above, as it is a composite key i was trying other ways.
Would you know how to connect a composite key to another table
ajetrumpet
03-06-2008, 09:45 AM
Would you know how to connect a composite key to another tableA composite key just means that you cannot have a one-to-many relationship between the two tables. I would think you could at least form another relationship of somekind, between a portion of your CK, and the table without a PK? What error are you getting?How do i connect a composite key to another table and allow the cascade deletion to be ticked.Without a one-to-many, I'm not sure if this is even possible...