Search code examples
vbat-sqlms-accesspass-through

Passthrough does not return decimal values anymore


Hope I don't ask an already existing question. Didn't find a solution on the internet after a couple of hours of search. I think this issue is pretty new, maybe caused by a recent update.

In my MS Access VBA code, I am using passthrough queries to get results from SPs on my MS SQL Server. For a few weeks now, I do not receive decimal values as results anymore, the values are just null in this case.

Here is a very easy code example:

Dim db As DAO.Database
Set db = CurrentDb
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset
Dim strSQL As String

strSQL = "SELECT 'abcde' AS string, '2020-07-01' AS date, 123.45 AS decimal, 3 as int"

Set qdf = db.CreateQueryDef("")
qdf.Connect = [here is my connectiong string]
qdf.SQL = strSQL
qdf.ReturnsRecords = True
Set rs = qdf.OpenRecordset

When working with that result, e.g. by copying that into an Excel file, the string; date, and integer value are written as required. Only the decimal value is a null instead.

Hope I didn't miss any essential information here. If you have any questions, just let me know.

Thanks for the help in advance!

BR, Martin


Solution

  • As it appears that your code was working and now isn't, it may be that you have encountered a recent bug in Microsoft Access: Access VBA/DAO code may crash or report incorrect data for Decimal columns which has now apparently been fixed.

    Regards,