DELETE FROM statement

J

Jochem Davids

I'm trying to run a DELETE sql statement, based on two ComboBoxes.

CurrentDb.Execute ("DELETE FROM tblOne WHERE tblTwo.[Id] <> " & cboId & "
AND tblname.[name] <> " & cboName & " "), dbFailOnError

Both seperate they work fine...This AND statement will not work?!
I also tried && ... What should I use?
 
S

Stefan Hoffmann

hi Jochem,

Jochem said:
I'm trying to run a DELETE sql statement, based on two ComboBoxes.

CurrentDb.Execute ("DELETE FROM tblOne WHERE tblTwo.[Id] <> " & cboId & "
AND tblname.[name] <> " & cboName & " "), dbFailOnError
You need to enclose the name in quotes:

AND tblname. said:
Both seperate they work fine...This AND statement will not work?!
I also tried && ... What should I use?
Create a query based on that conditions (you don't need the quotes here):

SELECT *
FROM tblOne
WHERE tblTwo.[Id] <> Forms!YourForm!cboId
AND tblname.[name] <> Forms!YourForm!cboName

Is there any data?


mfG
--> stefan <--
 
O

Ofer Cohen

If the [Name] Field is text type try adding single quote be fore and after

CurrentDb.Execute ("DELETE FROM tblOne WHERE tblTwo.[Id] <> " & cboId & "
AND tblname.[name] <> '" & cboName & "'"), dbFailOnError
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top