Hi: First thing to metion is that the result field I expect is a Memo Field
When I run the following (qry*)query in access I do get the expected one (row*)row as the result-However when I use this (modl*)code into an Excel VBA module-nothing happens- I tested for recorcound and it does show -1. Just wondering why I Am not getting the results when using VBA in Excel-Thanks in advance
****** IN ACCESS THIS WORKS FINE **********
(qry*)
SELECT Periods_Desc FROM FCST_Template_SGA GROUP BY Pull_Date, Template_Name, Periods_Desc HAVING Template_Name="AFTRHRS";
(row*)
JAN 08 ACTUAL-FEB 08 ACTUAL-MAR 08 ACTUAL-APR 08 ACTUAL-MAY 08 ACTUAL-JUN 08 ACTUAL-JUL 08 ACTUAL-AUG 08 ACTUAL-SEP 08 ACTUAL-OCT 08 6+6 FCST-NOV 08 6+6 FCST-DEC 08 6+6 FCST-
******HOWEVER IN EXCEL IT DOES NOT DISPLAY ANYTHING ****
(modl*)
Private Const cDir_Database As String = "C:\Documents and Settings\BLABLA\MRA_Database.mdb"
Public DB_Conn As ADODB.Connection 'Access connection
Public DB_RSet As ADODB.Recordset 'Access Record Set
Public DB_SQL As String 'SQL Commands
'======
Private Sub UserForm_Initialize()
Dim wbBook As Workbook
Dim wsSheet As Worksheet
Set wbBook = ActiveWorkbook
Set wsSheet = wbBook.Worksheets("SGA")
OPEN_DATABASE
'*** HEADER
DB_SQL = "SELECT Periods_Desc FROM FCST_Template_SGA GROUP BY Pull_Date, Template_Name, Periods_Desc HAVING Template_Name='" & "AFTRHRS_SF_UBH" & "';"
With DB_RSet
Application.StatusBar = "Checking Valid Source Codes..."
.Open DB_SQL, _
DB_Conn, _
adOpenForwardOnly, _
adLockReadOnly 'Open the list of Source Codes
MsgBox CStr(.RecordCount)
wsSheet.Range("A1").CopyFromRecordset DB_RSet
.Close
End With
CLOSE_DATABASE
End Sub
'===
Public Sub OPEN_DATABASE()
Application.StatusBar = "Connecting to the Database..."
Application.Cursor = xlWait
Set DB_Conn = New Connection 'Database Connection
Set DB_RSet = New Recordset 'Database RecordSet
DB_Conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & cDir_Database
DB_Conn.Open
DB_Conn.BeginTrans
Application.StatusBar = False
End Sub
'=====
Public Sub CLOSE_DATABASE()
Application.StatusBar = "Disconnecting from the Database..."
DB_Conn.CommitTrans 'Commit All Work
DB_Conn.Close 'Close the connection
Set DB_RSet = Nothing
Application.Cursor = xlDefault
Application.StatusBar = False
End Sub
Bookmarks