DELETE FROM statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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 <--
 
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
 
Back
Top