Hi all,
Not a programmer but am getting the "circular reference error" on a spreadsheet that I inherited. I am running the macro our former employee created, and I am getting:
"RunTime error 2147467259 (80004005)':
Circular Reference caused by alias 'Fiscal Year' in query definitions SELECT list."
So I tried to fix this by adding the fully qualified name, BECK MONTY.[Fiscal Year], but no luck.
Anyone know how to fix this Alias error? The Debug is taking me to line 9:
Sub BringInfo()
Dim Connection As ADODB.Connection
Dim rs As New ADODB.Recordset
Set Connection = New ADODB.Connection
detailsSource = ThisWorkbook.Path & "\" & ThisWorkbook.Name
Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & detailsSource & ";Extended Properties=""Excel 12.0 Macro;HDR=YES;"""
LastRow = getlastrow(ActiveSheet.Name, "A")
Query = "select[Period],val([Fiscal Year]) as [Fiscal Year],[Journal Cd],[Name],[Project Name],[Transaction Desc],[Amount],abs([Amount]),[Voucher Number],[Invoice ID],[Project ID] from [GLDetail$] where [Project ID]='" & Range("B1").Value & "'"
rs.Open Query, Connection
Range("A" & LastRow + 1).CopyFromRecordset rs
rs.Close
End Sub
Not a programmer but am getting the "circular reference error" on a spreadsheet that I inherited. I am running the macro our former employee created, and I am getting:
"RunTime error 2147467259 (80004005)':
Circular Reference caused by alias 'Fiscal Year' in query definitions SELECT list."
So I tried to fix this by adding the fully qualified name, BECK MONTY.[Fiscal Year], but no luck.
Anyone know how to fix this Alias error? The Debug is taking me to line 9:
Sub BringInfo()
Dim Connection As ADODB.Connection
Dim rs As New ADODB.Recordset
Set Connection = New ADODB.Connection
detailsSource = ThisWorkbook.Path & "\" & ThisWorkbook.Name
Connection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & detailsSource & ";Extended Properties=""Excel 12.0 Macro;HDR=YES;"""
LastRow = getlastrow(ActiveSheet.Name, "A")
Query = "select[Period],val([Fiscal Year]) as [Fiscal Year],[Journal Cd],[Name],[Project Name],[Transaction Desc],[Amount],abs([Amount]),[Voucher Number],[Invoice ID],[Project ID] from [GLDetail$] where [Project ID]='" & Range("B1").Value & "'"
rs.Open Query, Connection
Range("A" & LastRow + 1).CopyFromRecordset rs
rs.Close
End Sub