"Gargamil" <wo****@tpgi.com.au> wrote in message
news:cr**********@otis.netspace.net.au...
I've written a function to calculate a seriies of parameters based upon
some variables. I'd like to be able to return all the parameters to a
query. Now all the parameters are interrelated and cannot be calculated
seperately.
I suppose the question is, can I return multiple results from a function
to a query? Or am I limited to duplicating the query multiple times and
returnig one parameter each time?
g
Functions are normally used to return a single value of a particular type
(string, integer, boolean, etc) but you could write a function which returns
no value at all. However, this doesn't prevent you doing something like
passing 3 variables, changing their values and returning either true or
false to indicate whether the function changed them all as expected or not.
E.g.
Public Function GetMyValues(strFirstName As String, _
strLastName As String, _
dteDOB As Date) As Boolean
strFirstName = "Fred"
strLastName = "Bloggs"
dteDOB = DateSerial(1955, 12, 25)
GetMyValues = True
End Function
But this might not be so helpful with a query. Instead, you could calculate
one column and then pass that calculated value to a function to calculate
the next column, if that's the sort of thing you need. However, although
queries are great for many things, there are times when it might be better
to write a routine which creates a brand new table showing you the results
you need - you read one or more values from a table and use them to create a
single row in the results table.
Perhaps post more specific details of the values you need calculated.