Question : MS Access Query Error when executed from VBA with DMAX() function

I am getting an error when I attempt to execute a query using VBA in Access.  I am connecting to a separate access database using an ADO connection, and am getting an error whose description is "unknown".  I have tried to:
1) Save the query in access and execute as a "stored procedure" from VBA.
2) Execute the query as a command from VBA.
The error I receive is the same.  My query is below:

Saved as a query in Access:
UPDATE tbl_sourceLog AS s
INNER JOIN tbl_import AS i
ON s.source=i.Source
SET updated_source_version = DMax("updated_source_version","tbl_sourcelog")+0.1
WHERE i.validated Is Null
AND s.current="Y";

Saved in VBA:
 strsql = "UPDATE tbl_sourceLog AS s INNER JOIN tbl_import AS i ON s.[source] = i.[Source] " & _
               "SET updated_source_version = DMax(""updated_source_version"",""tbl_sourcelog"")+0.1 " & _
                "WHERE i.validated Is Null AND s.current=""Y"";"

Any insight will be helpful.

Answer : MS Access Query Error when executed from VBA with DMAX() function

I figured out a workaround.  First run a query to pull the max value from my table, and then use dynamic SQL to "hardcode" the value to be inserted where the DMAX() function was used.  Still not sure why the function won't work, but this will work for my purposes.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
strsql = "SELECT s.source, max(updated_source_version) + .1 as new_version from tbl_sourcelog AS s INNER JOIN tbl_import AS i on i.[source] = s.[source] " & _
                                    " where i.validated is null and s.[current] = ""N""  group by s.source;"
                            OpenAccessRecordset (strsql)
                            
                            If Not rsDB.EOF Then
                                strsql = "UPDATE tbl_sourceLog AS s INNER JOIN tbl_import AS i ON s.[source] = i.[Source] " & _
                                    " SET updated_source_version = '" & rsDB.Fields(1).Value & _
                                    "' WHERE i.validated Is Null AND s.[current]=""Y"" and s.[source] = """ & rsDB.Fields(0).Value & """;"
                                ExecuteCmd (strsql)
                            End If
Random Solutions  
 
programming4us programming4us