Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ou ou is offline
external usenet poster
 
Posts: 1
Default How to use QueryTable with insertion sql

Hi
I want to execute "insert into xxx" in the excel, but found that
everytime I need to specify a Range although the sql statement won't return
any data back. I really don't want to display anything inside excel when the
insertion is executed. So that's basically what I want and did:
I wrote a small GUI form inside the VB Editor of Excel. When the
user click some button on the form I will do an insertion. The following is
my code:

'oQts is the QueryTables collection of ActiveSheet
'lstConns let the user choose a connection string
'Range is where the data should go and my problem because I
don't want the data to appear on the excel
'sql is the insertion statement
Set oQt = oQts.Add(oQts.Item(lstConns.ListIndex + 1).connection,
Range("a1"), sql)
oQt.name = "MyTempTable"
'Execute the insertion
oQt.Refresh

Ok, that's what I tried to remove the "a1", I added after the code:
oQt.CancelRefresh
oQt.Delete
And the QueryTable is removed from the QueryTables but in the cell a1 I
still read "MyTempTable"

Is there anyway so that it won't appear on the excel? I tried to put the
Range("a1") as Range("") but the marco execution will fail


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default How to use QueryTable with insertion sql

"ou" wrote in message

I want to execute "insert into xxx" in the excel
everytime I need to specify a Range


You must specify the literal Range values in sql text e.g.

INSERT INTO MyTable (MyIntCol, MyTextCol) VALUES (1, 'One')

Jamie.

--
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
Webquery [querytable] long url LightShow Excel Discussion (Misc queries) 5 May 21st 07 11:09 PM
Bad QueryTable Row Count igneramos[_3_] Excel Programming 0 January 27th 04 10:21 PM
Querytable Ben.c Excel Programming 4 December 3rd 03 09:11 AM
Using VBA Copy/Paste and QueryTable Hudel H Excel Programming 0 November 17th 03 04:41 PM
MS QUERY w/out querytable No Name Excel Programming 1 October 24th 03 03:55 PM


All times are GMT +1. The time now is 11:21 PM.

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

About Us

"It's about Microsoft Excel"