MikeAngelastro
Registered User.
- Local time
- Today, 07:45
- Joined
- Mar 3, 2000
- Messages
- 254
Hi,
I am having a problem deleting records from a detail or line-item table. I have a PO table and a PO_Detail table. There are times when I must remove a PO from the tables and I am using the following code:
Private Sub RemovePO(PO_No As String)
'Remove this PO from the tables.
DoCmd.SetWarnings False
SQL = "DELETE * FROM PurchaseOrderDetail WHERE PO_Number = " & QUOTES & PO_No & QUOTES & ";"
DoCmd.RunSQL (SQL)
SQL = "DELETE * FROM PurchaseOrder WHERE PO_Number = " & QUOTES & PO_No & QUOTES & ";"
DoCmd.RunSQL (SQL)
DoCmd.SetWarnings True
End Sub
QUOTES = """" (This is my way of handling quotation marks in code generated SQL and it has always worked.)
The resulting SQL statements are per the immediate window:
?sql
DELETE * FROM PurchaseOrder WHERE PO_Number = "888880009";
DELETE * FROM PurchaseOrderDetail WHERE PO_Number = "888880009";
Problem: The first one works but the second one doesn't. The PurchaseOrder table has one record per PO.
The PurchaseOrderDetail table has one or more records per PO.
I am using Access 2002 with Windows XP.
Any ideas?
Thanks,
Mike
I am having a problem deleting records from a detail or line-item table. I have a PO table and a PO_Detail table. There are times when I must remove a PO from the tables and I am using the following code:
Private Sub RemovePO(PO_No As String)
'Remove this PO from the tables.
DoCmd.SetWarnings False
SQL = "DELETE * FROM PurchaseOrderDetail WHERE PO_Number = " & QUOTES & PO_No & QUOTES & ";"
DoCmd.RunSQL (SQL)
SQL = "DELETE * FROM PurchaseOrder WHERE PO_Number = " & QUOTES & PO_No & QUOTES & ";"
DoCmd.RunSQL (SQL)
DoCmd.SetWarnings True
End Sub
QUOTES = """" (This is my way of handling quotation marks in code generated SQL and it has always worked.)
The resulting SQL statements are per the immediate window:
?sql
DELETE * FROM PurchaseOrder WHERE PO_Number = "888880009";
DELETE * FROM PurchaseOrderDetail WHERE PO_Number = "888880009";
Problem: The first one works but the second one doesn't. The PurchaseOrder table has one record per PO.
The PurchaseOrderDetail table has one or more records per PO.
I am using Access 2002 with Windows XP.
Any ideas?
Thanks,
Mike