views:

241

answers:

2

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?

+2  A: 

Create a query that calls the function.

SELECT [FirstName], [Surname]
  FROM dbo.FindCustomersOrderByDesc();
Ardman
@Ardman, the function you calling here is a _table_ valued function. Do you know a simple way to call a _scalar_ function?
Skywalker
Yes, just do a SELECT function. This will give you the results you want. I added the table valued function in order to show you it's the same method.
Ardman
+1  A: 

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

Charles Robinson