1

I have an MS access 2010 database which is connected to a MS Excel 2010 for reporting purpose. I have linked the Excel to Access using Get External Data option in excel. With few changes in the reporting requirements I had to create a new query in Access (and it has some custom function). The Custom Function is a VBA module in Access.

Unfortunately when I use the Get External Data in Excel to link my new access query, the new query (View) is not listed on the list of Table/View (Import Wizard). When I remove the Custom Function the query is displayed in the wizard.

My Custom Function to Concatenate rows (taken from another site)

Public Function ConcatADO(strSQL As String, strColDelim, _
   strRowDelim, ParamArray NameList() As Variant)

   Dim rs As New ADODB.Recordset
   Dim strList As String

   On Error GoTo Proc_Err

       If strSQL <> "" Then
           rs.Open strSQL, CurrentProject.Connection
           strList = rs.GetString(, , strColDelim, strRowDelim)
           strList = Mid(strList, 1, Len(strList) - Len(strRowDelim))
       Else
           strList = Join(NameList, strColDelim)
       End If

       ConcatADO = strList

   Exit Function

Proc_Err:
       ConcatADO = "***" & UCase(Err.Description)
End Function

and following is the JET SQL used in the new query (which works absolutely fine within Access)

SELECT DISTINCT 
D.[Ref ID], 
D.[ENTRYDATE], 
D.[AUDITOR LID], 
D.[Process], 
D.[Auditee], 
D.[Auditee Name], 
D.[Account No], 
D.[Auditee Manager], 
D.[MaxScore], 
D.[Score], 
D.[Result], 
ConcatADO("SELECT [COMMENTS]  FROM ycube WHERE [Ref ID]="  & "'" & [d].[Ref ID] & "'" ,", "," : ") AS [Master Comment]
FROM ycube AS D;
  • Is it the limitation of Excel when we use Custom Function and
  • Is there a way around to import (rather link) above Access query to Excel
Community
  • 1
  • 1
Youbaraj Sharma
  • 1,295
  • 3
  • 17
  • 34
  • Looks like there is no way around to this and I have finally decided to change the complete table structure. Unfortunately Import Wizard does not allow any custom function in Jet SQL statement to proceed. – Youbaraj Sharma Nov 11 '14 at 20:37

0 Answers0