By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

function in query on diffrent rows

P: n/a
Hello,

I have put a function myfunc(val1, val2) which I call in a query. So far I
only have arguments from the actual row there is no problem. But I can't
make it working that i use a value from the next/last row? Is there any idea
out there?

Thanks
Stefan
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If you call a function in a query, it can only "see" the values in the
current record/row. If you need to get values from the next/last rows
you may need to use a recordset and go that way. You could declare a
few variables inside your function, go to the first/last/next/previous
records and write them to a variable so that you can do your
comparisons, and then just use the .Update method to save the value to
a field in a table.

Village Idiot
(Hey, go find your *own* village! This one's taken!)
Nov 12 '05 #2

P: n/a
Pieter Linden wrote:
If you call a function in a query, it can only "see" the values in the
current record/row. If you need to get values from the next/last rows
you may need to use a recordset and go that way. You could declare a
few variables inside your function, go to the first/last/next/previous
records and write them to a variable so that you can do your
comparisons, and then just use the .Update method to save the value to
a field in a table.


Hi Peter what do you mean with recordset ? How do I use a recordset in a
query? Or should I use it inside the function? But how to get a reference
back on the current record inside the function?

Thanks
Stefan
Nov 12 '05 #3

P: n/a
"Stefan Goerres" <li***@gsysteme.de> wrote in message news:<bj************@ID-8437.news.uni-berlin.de>...
Pieter Linden wrote:
If you call a function in a query, it can only "see" the values in the
current record/row. If you need to get values from the next/last rows
you may need to use a recordset and go that way. You could declare a
few variables inside your function, go to the first/last/next/previous
records and write them to a variable so that you can do your
comparisons, and then just use the .Update method to save the value to
a field in a table.


Hi Peter what do you mean with recordset ? How do I use a recordset in a
query? Or should I use it inside the function? But how to get a reference
back on the current record inside the function?

Thanks
Stefan


Stefan,
since a query looks across a record (unless it's a summary query,
where it looks across a set of records with some value(s) in common -
the ones it's grouped on), your scenario won't work. The single
record can't "see" the records above and below it. If you use a
function/subroutine and open a recordset (which you can define with a
query/SQL statement), you can go all over the place and do what you
want. Well, if you open an updateable recordset <g>. Could you give
a concrete example (but small/simple) of what you're trying to do?
Include about 5 records with as few fields as you can, but so it still
makes sense.
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.