Function with parameter in row source

  • Thread starter Thread starter =?windows-1257?Q?Linas_Petkevi=E8ius?=
  • Start date Start date
?

=?windows-1257?Q?Linas_Petkevi=E8ius?=

Hallo,

I would like my function with parameter to be row source of my combobox. What is syntax ? "Exec MyFunction(1)" does not works.
 
-----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-----
 
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.
 
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.
 
Back
Top