Update a Database From Excel
Hi All,
I am excuting a sql query to a DB to set a Field value to equal the current date:- The problem I have is in Cell A1 I get left "ExternalData_163" I added the Range("A1").Select and Selection.Clear to the end of the macro but it seems to get over looked. I changed the Refresh to .Refresh 'BackgroundQuery:=False but i get the following error messege " Run-time error '1004': Application-defined or object-defined error" Is there a way to send an update statement to a DB without the output been sent to the Worksheet? Many Thanks Mark Sub Update_Details_Sent() Range("A1").Value = Now() Range("A1").Select Selection.NumberFormat = "yyymmdd" NewDate = Range("A1").Text SQLQuery = "" SQLQuery = SQLQuery & "Update Stage1 Set ExcelDate = '" & NewDate & "' " SQLQuery = SQLQuery & "where ExcelDate = '20050101' " connstring = "ODBC;DSN=*******;Database=********" With ActiveSheet.QueryTables.Add(Connection:=connstring , _ Destination:=Range("A1"), Sql:=SQLQuery) .Refresh End With Range("A1").Select Selection.Clear End Sub |
All times are GMT +1. The time now is 09:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com