Delete record using vba

  • Thread starter Thread starter .Len B
  • Start date Start date
L

.Len B

I have a table whose primary key is text (length 50).
I need to programmatically delete one record.

What is the best way, just use DoCmd.RunSQL or is there
a better way? I know the PK.
 
Hi Len,

..Len B said:
I have a table whose primary key is text (length 50).
I need to programmatically delete one record.

What is the best way, just use DoCmd.RunSQL or is there
a better way? I know the PK.

i would use CurrentDb.Execute "DELETE * FROM ..."
because this will not generate a warning like DoCmd.RunSQL will do.
 
| Hi Len,
|
| .Len B schrieb:
| > I have a table whose primary key is text (length 50).
| > I need to programmatically delete one record.
| >
| > What is the best way, just use DoCmd.RunSQL or is there
| > a better way? I know the PK.
|
| i would use CurrentDb.Execute "DELETE * FROM ..."
| because this will not generate a warning like DoCmd.RunSQL will do.
|
| --
| Gruß, Bernd
| ---
| Access goes Subversion - http://oasis.dev2dev.de


Thanks very much Bernd. I was wondering how to suppress the warning.
I'm not using * though. My string worked using RunSQL. Since I only
want to kill one record I guess it makes no difference.
"DELETE FROM tblSuspended WHERE LogonName = '" & gstrLogonName & "'"
 
Back
Top