Function Problem

V

vichet

Hi All;

I have create one UDF that return nvarchar.
i.e. my function name myFun.

In access2003, i want to get the value from that function to one variable.

how do i?

thank
 
N

Norman Yuan

If you are talking UDF in SQL Server and trying to use it in your Access ADP
frontend's VBA code, the answer is no: UDF runs inside SQL Server, the
backend, while your Access ADP VBA code runs in, well, Access ADP, the
frontend. UDF is meant to be used for qerying the SQL Server, such as in
SPs.

You could "indirectly" use the UDF in you Access ADP's VBA code to get a
value being returned from SQL Server, though. Such as:

Dim str as String
str=GetMyValueFromDB()

Private Function GetMyValueFromDB() As String

'' Declare a ADO Command object

'' Add input/output parameters as you need

'' Execute the Command, which call a SP in SQL Server, which in turn
calls your UDF.
''The value return by the UDF get passed back to your VBA code in the
form of output parameter

GetMyValueFromDB=cmd.Paramater("OutputParam").Value

End
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top