Delete Query

  • Thread starter Thread starter Dinsdale
  • Start date Start date
D

Dinsdale

Hi All,

I am converting an Access Query for VBA code with the resulting code here:

dbs.Execute "DELETE * from [SPI Info for Report]" _
& WHERE 'Candidate ID'=[forms]![Candidate Data]![Candidate ID]));"

When I test run it the code deletes all EXCEPT the Candidate ID selected.
Any thoughts?

TIA

Andrew
 
Your quotes aren't right. It should be:

dbs.Execute "DELETE * from [SPI Info for Report] " _
& "WHERE [Candidate ID]=" & [forms]![Candidate Data]![Candidate ID]

Make sure you have the space at the end of the first line right before the
last qouble-quote to separate the table name from the WHERE. I'm assuming
Candidate ID is a numeric field - if not, you would have to put quotes around
the forms!... value. Also, if 'Candidate ID' does have a space in it, I'm
pretty sure you have to put the brackets around it. I personally NEVER use
spaces in field names.
 
Thanks Jim. Thought it would have been sytax.

Andrew

Jim Burke in Novi said:
Your quotes aren't right. It should be:

dbs.Execute "DELETE * from [SPI Info for Report] " _
& "WHERE [Candidate ID]=" & [forms]![Candidate Data]![Candidate ID]

Make sure you have the space at the end of the first line right before the
last qouble-quote to separate the table name from the WHERE. I'm assuming
Candidate ID is a numeric field - if not, you would have to put quotes around
the forms!... value. Also, if 'Candidate ID' does have a space in it, I'm
pretty sure you have to put the brackets around it. I personally NEVER use
spaces in field names.

Dinsdale said:
Hi All,

I am converting an Access Query for VBA code with the resulting code here:

dbs.Execute "DELETE * from [SPI Info for Report]" _
& WHERE 'Candidate ID'=[forms]![Candidate Data]![Candidate ID]));"

When I test run it the code deletes all EXCEPT the Candidate ID selected.
Any thoughts?

TIA

Andrew
 
Back
Top