473,775 Members | 2,625 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function in query on diffrent rows

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
3 4236
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
9122
by: muelli75 | last post by:
Hi! Im getting insane by solving a problem .... I try to define a function which uses a code-snippet from another file. My base are the codes from the great book "WebDataBase-Book by H. Williams & D. Lane". So I try to use
4
4599
by: Graham Leggett | last post by:
Hi all, I am trying to do a query that returns all rows that are _not_ part of a join, and so far I cannot seem to find a query that doesn't take 30 minutes or more to run. The basic query is "select * from tableA where tableA_id NOT IN (select tableA_id from tableB)". Is there a more efficient way of doing this?
5
6062
by: Jim | last post by:
Need help with aggregate function...for each unique product, I need the provider with the cheapest cost factor Here't the table (Table1) ID product provider factor 1 123456 abc .050 2 123456 def .035 3 666666 def .040 4 123456 ghi .080
2
1775
by: icyajax | last post by:
HI All, I m trying to write an SQL query in VBA to a sql string. It will be used for a search form. I want the query to evaluate multiple text boxes filled in by the user. For example, they are fields like street name, street type, house number. If the user inputs say Street name and Street type , 'abc st', the query should evaluate both the fields entered by the user and search for it and provide results which correspond to the entered fields...
3
1773
by: Frank11 | last post by:
Hi, I'm rather new to writing queries, so please forgive me if this is a really simple thing to do. I need to create a query that finds out which rows in the DB have ANY of the values that are in a given list. Only one column in each row of the DB has their values stored in a list. Example: Passed list = 2,5,10,6 ColumX data in database: Row 1 = 3, 5, 21, 4
4
2046
by: ilikebirds | last post by:
SO table tqcmain1 has 26 records. My goal is to Show all of the tqcmain1 data with the employee_id from MakeUnion90days where the order_number and step_found match. So ideally I want the same 26 records with Employee_ids. However I run this query and it returns 28 records. I know the makeunion90days table has extra information. Is there anyway to only Show the 26 records with the Tqcmain1 data with the additional...
3
1334
by: aineclal | last post by:
Hi I'm trying to run two count querys on one column in access. its like an if statement, i want to count all rows where sale >=40 and name as pass and a second column where sale is <=39 as fail. can anyone help please?
1
2178
by: ArunDhaJ | last post by:
Hi, Can we write custom function to filter rows from DataTable Select method? Actually my need is to format the row value from (901) 789 1234<BR>(901) 789 1235<BR>(901) 789 1221 to 9017891234<BR>9017891235<BR>9017891221 (removing all formatting strings)
2
2083
by: kkshansid | last post by:
same query return rows in mysql but not on php page while($rs = mysql_fetch_array($sql2)) { $town=$rs; $q="select * from institute where address like '%".$town."%'";//this query //echo $town; echo $q;//same query return rows in mysql //exit(); $sql3 = mysql_query($q);
0
9622
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10048
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.