Hi All,

I am having issues with the code below. The code works in 2010, but not in 2013. Can anyone tell me why it will not work in 2013?

I am running a 64 bit machine, the 2010 machine is a 32 bit. Not sure if that has anything to do with the problem.



Public Function GetPriceInfo(IndexNum As String, Optional PubMonth As String, Optional BeginDate As String, Optional EndDate As String, Optional Refresh As Integer)

'Need to have Microsoft DAO 3.6 Object Library referenced, Microsoft Jet and Replication Objects 2.6 library, Microsoft ActiveX Data Objects 6.1 library, MIrcosoft Access 15.0 Object Library

'************************************************************************************************************************************
'************************************************ List of Index Numbers stored in \\enogexdata\WHEEERRRREE ************************************************
'************************************************************************************************************************************

Dim sql As String
Dim rtnArray(0) As Variant
Dim db As New ADODB.Connection
Dim mrs As New ADODB.Recordset
Dim DBPath As String
Dim sconnect As String


'Dim FuncName As String
'Dim FuncDesc As String
'Dim Category As String
'Dim ArgDesc(1 To 5) As String

'FuncName = GetPriceInfo
'FuncDesc = "Returns the Inside FERC or average gas daily price for a given time period"
'Category = 1
'ArgDesc(1) = "Index Number from MRC Price Database."
'ArgDesc(2) = "First day of month for Inside FERC prices" ' Was previously Flow Month
'ArgDesc(3) = "Beginning flow date for GDD prices"
'ArgDesc(4) = "Ending flow date for GDD prices"
'ArgDesc(5) = "1 for refresh"

'Body of function


DBPath = "\\enogexdata\Share\Nerve Center\Commodity Management\Market Risk Committee\MRC Price Database.mdb"
sconnect = "Provider= Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & DBPath & ";"
db.Open sconnect

'Set db = OpenDatabase("\\enogexdata\Share\Nerve Center\Commodity Management\Market Risk Committee\MRC Price Database.mdb", , True)


'Inside FERC SQL
If BeginDate = "" Then

sql = "SELECT Price as IndPrice FROM [tblDailyPrices] "
sql = sql & "WHERE PubDate = #" & PubMonth & "# "
sql = sql & "AND DailyIndexID = " & IndexNum & " "

'GDD SQL
Else

sql = "SELECT AVG(Price) as IndPrice FROM [tblDailyPrices] "
sql = sql & "WHERE FlowDate >= #" & BeginDate & "# AND FlowDate <= #" & EndDate & "# "
sql = sql & "AND DailyIndexID = " & IndexNum & " "

End If

mrs.Open sql, db, adOpenStatic, adLockReadOnly

If mrs.EOF Then
rtnArray(0) = ""
Else
rtnArray(0) = mrs!IndPrice
End If
mrs.Close
db.Close
GetPriceInfo = rtnArray(0)


End Function