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: 11
Default Macro to import external data from Access query to Excel

I have tried to post this a couple times, but don't see it after I post it...
so if it out here three times, I am sorry!

I am trying to write code that will allow me to pull in information for
different areas depending on the file that I am creating. For example, I
will create a file for US006 and want the external information for US006 and
then create a file for US007 and want the information for US007.

I created the code below. The fourth line from the bottom references US006.
I would like that to be a variable dependent on the file I am creating. I
cannot seem to get it to work.

Is this doable?

Thanks for your help.

Sub Macro7()
With Selection.QueryTable
.Connection = Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=C:\Documents and
Settings\ruffnro\My Documents\__Reporting\Monthly Reporting\_ Financial
Reporting.m" _
), Array( _
"db;DefaultDir=C:\Documents and Settings\ruffnro\My
Documents\__Reporting\Monthly Reporting;DriverId=25;FIL=MS Access;MaxBufferS"
_
), Array("ize=2048;PageTimeout=5;"))
.CommandText = Array( _
"SELECT inventory.Area, inventory.`Client No`, inventory.`Client
Name`, inventory.SEC, inventory.`CP Name`, inventory.`Net Unbilled`,
inventory.`Net Billed`, inventory.`net Invty`" & Chr(13) & "" & Chr(10) &
"FROM inventory inven" _
, "tory" & Chr(13) & "" & Chr(10) & "WHERE (inventory.Area='US006')")
.Refresh BackgroundQuery:=False
End With
End Sub

 
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
Macro to import external data from Access query to Excel Kou Vang[_2_] Excel Programming 0 November 25th 09 04:21 PM
Import external data from Access query with Variable ruffnro Excel Programming 1 November 24th 09 07:59 PM
vba code to import access query data into excel spreadsheet TechyTemp Excel Programming 2 February 6th 07 03:26 PM
Create Excel PivotTable that uses Access query as external data so alexhatzisavas Excel Programming 0 August 30th 05 08:06 AM
VB Code or Excel macro to run Query/Import on Access file Harry[_8_] Excel Programming 13 February 22nd 05 07:27 PM


All times are GMT +1. The time now is 06:16 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"