Function with parameter in row source

L

Linas Petkevièius

Hallo,

I would like my function with parameter to be row source of my combobox. What is syntax ? "Exec MyFunction(1)" does not works.
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

You cannot Execute a function. Why not put the function call in a
stored procedure then call the stored procedure w/ the parameter. Call
the function using the passed parameter.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQUIN74echKqOuFEgEQKltACdGhu0uyJm3+J+METpyh2OP8XtQMAAoMVd
wkVqFXBgFheTChWDNbiRjtqT
=Tk9n
-----END PGP SIGNATURE-----
 
S

Sylvain Lafontaine

First, you can set the rowsource to the following:

select * from dbo.MyFunction(1)

Reset the rowsource inside code each time you want to make a requery with a
different value. The .Requery method will be called automatically by Access
if you change the rowsource of your control.

Second, you should use stored procedures instead of functions, as they are
much more convenient in SQL. Enclose your function inside a SP if necessary.
When calling as SP, drop the parenthesis and the Exec and don't forget to
put the dbo. prefixe.

S. L.
 
S

Sylvain Lafontaine

You're right, functions should be and are more convenient when used inside a
stored procedure or when working directly on the SQL-Server from the Query
Analyser.

But when you are working from an Access / ADP project, SP seems to be more
convenient than functions. For example, you can use stored procedures with
parameters and having these parameters recomputed automatically when doing a
requery; something you can't do with functions without having to reset the
rowsource each time. Maybe it is simply because I don't know the exact
syntax for calling a function with parameters from ADP but I never seen
someone coming with an answer to your question; which is quite common on
this newsgroup.

When used an in ADO call to retrieve a recordset, it is also a common
thinking by many people that you should use SP instead of functions.

S. L.
 

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