I don't use parameter queries much myself, but have you tried...
Sub doit(bNum As Long)
Dim sqlStr As String
Dim db As Databse
Set db=CurrentDB
sqlStr ="DELETE batchnummer.*, batchnummer.batchnummer FROM batchnummer
WHERE"
sqlStr =sqlStr & " (batchnummer.batchnummer = " & bNum & ");"
db.Execute sqlStr, dbFailOnError
End Sub
Add whatever error traping you need to ensure success.
Mike Storr
www.veraccess.com
"hpi" <nomail@hotmail.com> wrote in message
news:40112c3e$0$259$4d4ebb8e@read.news.nl.uu.net.. .[color=blue]
> 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
>
>[/color]