I'm trying to delete a single record in a Access database using the primary key of the record.
Dim sSQL As String
Set conn = New ADODB.Connection
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
sSQL = "DELETE FROM IdeDB WHERE tbIde = '" & tbOpgaveNr & "'"
Set conn = Nothing
DBsti (Path to database)
tbIde (Primary key)
tbOpgaveNr (Number (primary key) of record shown in userform)
If I change form primary key to a natural key it works fine but when I run the code I get an error from program line conn.Execute sSQL
"Runtime error 2147217904(80040e10) No value given for one or more required parameters"
I have also tried changing the code to:
sSQL = "DELETE FROM IdeDB WHERE tbIde = " & tbOpgaveNr & ""
and it is still the same.
What am I doing wrong