Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 16
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Security update KB905756 problem with Excel 2003 Peter20006 Excel Discussion (Misc queries) 0 March 23rd 06 09:19 PM
How do I update data in 3 related files in Excel? Vellarian Excel Discussion (Misc queries) 0 March 2nd 06 06:17 AM
Excel Links Update TracyB Links and Linking in Excel 0 February 21st 06 01:48 PM
how to automate invoice using excel database Kathy Powercraft Excel Discussion (Misc queries) 1 October 6th 05 02:29 PM
Update a Database Using Excel Dmorri254 Excel Worksheet Functions 1 April 11th 05 07:56 PM


All times are GMT +1. The time now is 08:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"