Deleting a record

I have a database with a table called Category.  It has several records.
I have a variable
Category = "xxx"

Set dbtemp = OpenDatabase(dbname)
    dbtemp.Execute "DELETE * FROM " _
        & "Category WHERE Category.Category = " & Category
    dbtemp.Close

I get an error" Too few parameters"
What am I doing wrong?  
Lee5Asked:
Who is Participating?
 
manojaminConnect With a Mentor Commented:
I am glad that worked...

If the Category filed in the Category table is of type String, Do this,

Set dbtemp = OpenDatabase(dbname)
    dbtemp.Execute "DELETE * FROM " _
        & "Category WHERE Category.Category = '" & Category & "'"
    dbtemp.Close


You need "'" & varname & "'" for String type fileds..

This will work...
0
 
manojaminCommented:
If the Category filed in the Category table is of type String, Do this,

Set dbtemp = OpenDatabase(dbname)
    dbtemp.Execute "DELETE * FROM " _
        & "Category WHERE Category.Category = '" & Category & "'"
    dbtemp.Close


You need "'" & varname & "'" for String type fileds..

This will work...
0
 
mark2150Commented:
Drop the * after the DELETE ...

M
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
mark2150Commented:
Also, it's poor practice to make the field name and the table name the same. This tends to lead to confusion...

M
0
 
Lee5Author Commented:
manojamin

Thanks, that works just fine.
Make it an answer
0
 
mark2150Commented:
Use the new "Grade Comment as Answer" feature...

M
0
All Courses

From novice to tech pro — start learning today.