Calling a MS SQL Server scalar UDF from vba

2019-05-22 19:36发布

问题:

I am programming an Access 2007 (accdb, not adp) frontend at connect to a SQL Server 2005 backend. How can I call a scalar user defined function from my vba code?

回答1:

Dim rst As ADODB.Recordset
Set rst = Connection.Execute("SELECT dbo.MyFunction('" & Me.field & "')")


回答2:

Create a query that calls the function.

SELECT [FirstName], [Surname]
  FROM dbo.FindCustomersOrderByDesc();