Delete query

  • Thread starter Thread starter Alan T
  • Start date Start date
A

Alan T

I have created a query:
DELETE
FROM Employee
WHERE Number = [Num]


Dim currDB As Database
Dim qryDeleteItems As QueryDef

Set currDB = CurrentDb
Set qryDeleteItems = currDB.QueryDefs("qryDeleteItems")
qryDeleteItems.Parameters("Num") = currNumber

What should be the statement after that?
qryDeleteItems.OpenRecordSet() ?
Or other?
 
I have created a query:
DELETE
FROM Employee
WHERE Number = [Num]


Dim currDB As Database
Dim qryDeleteItems As QueryDef

Set currDB = CurrentDb
Set qryDeleteItems = currDB.QueryDefs("qryDeleteItems")
qryDeleteItems.Parameters("Num") = currNumber

What should be the statement after that?
qryDeleteItems.OpenRecordSet() ?
Or other?

qryDeleteItems.Execute, dbFailOnError

and be sure there's an On Error GoTo Proc_Error before this code, and a

Proc_Exit:
Exit Sub
Proc_Error:
<do something appropriate to report the error>
Resume Proc_Exit

before the end of the routine.

John W. Vinson [MVP]
 
Hi,

What will be the arguments?
I got a runtime error about the arguments.


John W. Vinson said:
I have created a query:
DELETE
FROM Employee
WHERE Number = [Num]


Dim currDB As Database
Dim qryDeleteItems As QueryDef

Set currDB = CurrentDb
Set qryDeleteItems = currDB.QueryDefs("qryDeleteItems")
qryDeleteItems.Parameters("Num") = currNumber

What should be the statement after that?
qryDeleteItems.OpenRecordSet() ?
Or other?

qryDeleteItems.Execute, dbFailOnError

and be sure there's an On Error GoTo Proc_Error before this code, and a

Proc_Exit:
Exit Sub
Proc_Error:
<do something appropriate to report the error>
Resume Proc_Exit

before the end of the routine.

John W. Vinson [MVP]
 
Hi,

What will be the arguments?
I got a runtime error about the arguments.

Please post your code and the actual error message. Did you use Debug...
Compile <your project> after editing the code? If not, do so - it will point
out any errors.

John W. Vinson [MVP]
 
Sorry, my mistake.
It works.

John W. Vinson said:
Please post your code and the actual error message. Did you use Debug...
Compile <your project> after editing the code? If not, do so - it will
point
out any errors.

John W. Vinson [MVP]
 
Back
Top