SQL Delete Record using Excel VBA

S

steve

I have no problem reading, writing and counting from a table using this VBA /
SQL connection, but when I try to delete a record it does nothing. Any
suggestions would be welcome. Sometimes I get nothing, but lately I've been
getting a 1004 'General ODBC error.'



Thanks, Steve


Here's my code:
Dim SH As Object
Set SH = Sheet1
With SH.Range("Query_from_Loewenpr").QueryTable
.Connection = "ODBC;DSN=loewenpr;"
.CommandText = Array( _
"DELETE FROM DBPR.DHXSLRTLIB.DHLOC " & _
"WHERE DHLOC.BUSINESS_UNIT = '" & "DHTEST" & _
"')" _
)
.BackgroundQuery = False
.Refresh BackgroundQuery:=False
End With
 

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