LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default VB Code for MS Query

Hi Everyone,
I have a piece of code in Excel 2000 to retrieve some
data from Access 2000 using MS Query and it works fine.
The problem is that I need to copy down the formulas to
the right of the data and it does not do it even tough I
have the line: FillAdjacentFormulas=True on it.
The funny thing is that if I do a straight "refresh" in
the worksheet it copies all the formulas perfectly. The
reason why I need to do it using a macro is because I
need the user to select some criteria from another
worksheet. (I tested this and it works too)

Here's the code:

With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y(
_
"ODBC;DSN=MS Access Database;DBQ=S:\FF
Files\Profit Model.mdb;DefaultDir=S:\FF
Files;DriverId=25;FIL=MS Access;MaxBufferSize=" _
), Array("2048;PageTimeout=5;")),
Destination:=Range("A10"))
.CommandText = Array( _
----SQL Statement Here----
.Name = "Query from MS Access Database"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = True
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

Is there anything that I am missing or doing wrong?
I thank you all in advance
Gustavo
 
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
QUERY & HELP: so slow executing VBA code... :S John Keith Excel Worksheet Functions 3 February 13th 06 03:47 PM
how can i query an sheet with a where clause....from c# code using GAC.Me.Up.baby Charts and Charting in Excel 0 November 30th 05 09:11 PM
Code Query JohnUK Excel Programming 4 June 2nd 04 09:40 PM
Query on small piece of code Mike[_65_] Excel Programming 7 March 4th 04 03:23 PM
query source code Mel[_7_] Excel Programming 1 August 29th 03 11:24 PM


All times are GMT +1. The time now is 07:04 AM.

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"