Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Where do I paste in the following Access SQL code into my routine?

Access code:

SELECT AXA_BILLING1.[Profile Name], Sum(AXA_BILLING1.[Parts In]) AS
[SumOfParts In], Sum(AXA_BILLING1.[Parts Out]) AS [SumOfParts Out]
FROM AXA_BILLING1
GROUP BY AXA_BILLING1.[Profile Name];


VBA code:

Dim conDB As ADODB.Connection
Dim recDB As ADODB.Recordset
Dim i As Integer

Sheets("NDM-Assoc").Select
Range("A1:E65500").Select
Selection.ClearContents

i = 1

Set recDB = New ADODB.Recordset
Set conDB = New ADODB.Connection

conDB.CursorLocation = adUseClient

conDB.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=G:
\AUDASTAT\NORWICHU\Spreadsheets\NU-NDMs.mdb;;Jet

OLEDB:Database Password=;"

recDB.Open "SELECT * FROM [NDM-Assoc] ORDER BY SITEID", conDB

Do While Not recDB.EOF
Range("F" & i).Value = recDB!Initials
Range("G" & i).Value = recDB!Type
Range("H" & i).Value = recDB!SiteID

If IsNull(recDB!CatOrGEO) Then
Range("I" & i).Value = " "
Else
Range("I" & i).Value = recDB!CatOrGEO
End If

recDB.MoveNext
i = i + 1
Loop

recDB.Close

Columns("F:I").Select
Selection.Copy
Range("A1").Select
ActiveSheet.Paste


Thanks

Simon
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
VB code to run a Query in Access and paste results onto an Excelworksheet Tony Bender Excel Programming 5 October 1st 08 08:00 PM
How can I see assembly code for VBA routine? joeu2004 Excel Programming 2 January 17th 08 03:44 AM
Converting a Access routine into an Excel macro? turtle[_2_] Excel Discussion (Misc queries) 2 February 21st 07 06:38 PM
help w/ generic copy & paste/paste special routine DavidH[_2_] Excel Programming 5 January 23rd 06 03:58 AM


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