Followed through several threads on SO and couldn't find enough information to fix my problem. One of the sheets in my workbook is a table I need to query with SQL. It's a named Table. Here's the function I wrote in VBA:
Function getPowerPoints(eventID, resultTime) As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
strFile = ThisWorkbook.FullName
strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFile _
& ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"";"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open strCon
strSQL = "SELECT max(POINTS) FROM PowerPoints WHERE EVENT = " & eventID & " and TIME >= " & resultTime ''Named range
rs.Open strSQL, cn
getPowerPoints = rs.GetString
cn.Close
Set rs = Nothing
Set cn = Nothing
End Function
When I try to use the function in my worksheet, I just get a #NAME?
error with no helpful messages anywhere. How do I begin to debug this?