Invoke MS Access Query which calls a VBA Function in a Module from Delphi ADO Component

南笙酒味 提交于 2019-12-10 15:24:44

问题


I created a function in an MS Access Module, let's say Calculate(A, B).

I also created a Query in MS Access to use this function, let's say:

UPDATE aTable 
SET aField = Calculate(bField, cField)

How can I invoke the query, since I tried using: adoConnection.Execute, adoTable, adoQuery, adoCommand, and StoredProcedure, all reject it with the message

Undefined function Calculate in expression

Thank you in advance.


回答1:


You can't.

Queries using user-defined VBA functions can only be executed by the Access Application object, and only through the DoCmd.OpenQuery and DoCmd.RunSQL methods.

Instead, use COM and the Access Application object to automate the task. Do note this will cause considerable overhead. Or, when possible, do the calculation in the SQL clause.

They're not available through ODBC or OLEDB, thus not available in ADO.

If the full version of Access (not runtime version or database engine) isn't available, you unfortunately can't run queries that use user-defined VBA functions.



来源:https://stackoverflow.com/questions/53478882/invoke-ms-access-query-which-calls-a-vba-function-in-a-module-from-delphi-ado-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!