Hello,
I have a table : Batch
It contains fields
batchnummer : Number (Long Integer)
datum : Date/Time
status : Number (Long Integer)
nr_records : Number (Long Integer)
It contains a number of records and I want to delete the record with a
specific batchnummer eg 89
I created a querydef "Delete Batch by Batchnummer"
PARAMETERS batchnummer Long;
DELETE *
FROM batch
WHERE batchnummer=[batchnummer];
This is the VB code I used
Sub doit()
Dim qd As QueryDef
Set qd = CurrentDb.QueryDefs("Delete Batch by Batchnummer")
qd.Parameters("batchnummer") = 89
qd1.Execute
End Sub
After running this procedure ALL records are gone from the Batch table.
I also tested this for other similar tables and I had the same problem.
If I use a 'normal' query which selects records (no deletion) AND I use a
recordset (qd.openrecordset(...))
then it seems to work. But I can't use a recordset when I want to do a
delete.
I know, I can use a construction where I create a string containing the
where clause and run it using
docmd.RunSQL but I'm just wondering why this doesn't work.
Thanks
Hans