Microsoft Jet OLEDB 4.0 SQL Function Reference with ADO?

Tommy O'Dell picture Tommy O'Dell · Jan 7, 2012 · Viewed 9.2k times · Source

I'm using the the Microsoft.Jet.OLEDB.4.0 provider in Excel VBA ADO to connect to .csv and .xls files stored locally. I'm using the list of MS Access functions here as a guide for what I can write in SQL for Jet. But not all functions are supported and I'm having issues figuring out the syntax for certain things.

Question 1

Is there a reference somewhere for the set of SQL functions that I can use in my Jet queries through ADO?

Question 2

What's the right syntax for an IF (or CASE) statement? Without the IF, the query below runs fine.

    sql = "            SELECT "
    sql = sql & "        Date() as `Import Date`, "
    sql = sql & "        `Name` as `User`, "
    sql = sql & "        `Role Title` as `Role`, " 
    sql = sql & "        If 1=1 Then 1 Else 0 EndIf as `testing` "
    sql = sql & "      FROM [Sheet1$] a "

Resources

I don't see what I'm looking for in any of the answers provided here, here and here.

This looks like it should be the right place but it doesn't seem to show how to use IF/CASE in a SELECT statement, or what string functions are available

http://office.microsoft.com/en-us/access-help/CH006252688.aspx

Answer

Doug Glancy picture Doug Glancy · Jan 7, 2012

For question 1, this SO answer lists some good resources, including a link to an Intermediate SQL for Jet 4.0 article.

For question 2, do a search for the Iif and Switch functions.