1

Topic: Maximum from Recordset

Whether prompt, please, it is possible from already launched Recordset to pull out the information on the maximum value from different fields?
How?
Request for example

SELECT ID, YEARNUM, TEMPERATURE, CITY
FROM WEATHER

And here to learn about what year (YEARNUM) from us statistican is
____
vk.com/taenfox

2

Re: Maximum from Recordset

MokeevP wrote:

and here to learn about what year (YEARNUM) from us statistican is

And what criterion (how to define) that statistics is or it is not present (any field is filled / empty somewhere the flag or what other sign as differently is installed?

3

Re: Maximum from Recordset

sdku wrote:

it is passed...
And what criterion (how to define) that statistics is or it is not present (any field is filled / empty somewhere the flag or what other sign as differently is installed?

Perhaps, I paraphrase
The same effect as from function max is necessary to me, that is what last year is specified or to reassort on triggered request on increase, for example and to take the last value
I simply very much would not like to launch two similar requests simultaneously.
Or all a decay?

4

Re: Maximum from Recordset

MokeevP wrote:

I simply very much would not like to launch two similar requests simultaneously.

And it is necessary... However, you can launch them sequentially, which on maxima - probably, the first.

5

Re: Maximum from Recordset

MokeevP wrote:

the same effect as from function max is necessary to me, that is what last year is specified....

If the effect "is necessary as from function max" why it not to use And unless it not the same ( I do not understand, however):

SELECT TOP 1 year FROM ORDER BY year DESC

6

Re: Maximum from Recordset

Akina, it will be simple the general circuit approximately such:

Dim rs as dao.recordset, x = integer, y = integer
set rs=currentdb.openrecordset ("table")
do while x=0
y = currentdb.openrecordset ("SELECT max (YEARNUM) as MaxYear From table")! MaxYear
with rs
rs.addnew
rs! YEARNUM = y+1
rs.update
rs.addnew
rs! YEARNUM = y-1
rs.update
rs.addnew
rs! YEARNUM = y+2
rs.update ', etc.
end with
loop

It takes place to be or I is absolutely not right?
P.S. Do not consider semantic loading of arithmetical actions in the course of time, it there is not present

7

Re: Maximum from Recordset

MokeevP, there is a clone .

8

Re: Maximum from Recordset

sdku wrote:

it is passed...
If the effect "is necessary as from function max" why it not to use And unless it not the same ( I do not understand, however):

SELECT TOP 1 year FROM ORDER BY year DESC

It not on  :-)
He writes that

wrote:

from already launched Recordset

So a cycle on a dial-up :-(

9

Re: Maximum from Recordset

sdku;
Your variant is pleasant to me than that more that I above wrote smile
But a question essence in that not to use two requests, and all to squeeze out and suck round from one

10

Re: Maximum from Recordset

About, at  the dinner began:D
All thanks for attention)

alecko wrote:

MokeevP, there is a clone .

How it to do?

bubucha wrote:

so a cycle on a dial-up :-(

How here specified?

11

Re: Maximum from Recordset

MokeevP wrote:

the general circuit will be approximately such

In the shown circuit value

y = currentdb.openrecordset ("SELECT max (YEARNUM) as MaxYear From table")! MaxYear

there is a constant which can be carried out safely for cycle limits.

12

Re: Maximum from Recordset

Link certainly it is excellent, and briefly

dim rs as recordset, rsc as recordset
set rs=currentdb.openrecordset ("table")
set rsc=rs.clone
' the clone is a picture  in a present state, therefore after determination of maxima/minima and before change _
 the clone is necessary for closing.

13

Re: Maximum from Recordset

_, thanks for a link!

alecko wrote:

a link certainly it is excellent, and briefly

dim rs as recordset, rsc as recordset
set rs=currentdb.openrecordset ("table")
set rsc=rs.clone
' the clone is a picture  in a present state, therefore after determination of maxima/minima and before change _
 the clone is necessary for closing.

Thanks for clarification, only all the same are not clear as it to filter "on the move" smile

Akina wrote:

there is a constant which can be carried out safely for cycle limits.

As so when after each pass of a cycle new values YEARNUM are added? I missed something?

14

Re: Maximum from Recordset

MokeevP;
On a question

wrote:

and here to learn about what year (YEARNUM) from us statistican is

The answer is already given, but with the registration

wrote:

As so when after each pass of a cycle new values YEARNUM are added? I missed something?

The task is not clear, moreover, it is the multiple user task, or not... Describe the task for

wrote:

do not consider semantic loading of arithmetical actions in the course of time, it there is not present

adds clearness a little
From what you decided, what bypass in a cycle  will be faster, what two requests?

15

Re: Maximum from Recordset

MokeevP wrote:

after each pass of a cycle new values YEARNUM are added?

And it is stupid to look, how many it is as much as possible added, and  it is so much to a variable in the end of the next coil of a cycle instead of once again climbing in the table - not? Or you suppose, what it suddenly yes does not register?

16

Re: Maximum from Recordset

bubucha wrote:

MokeevP;
On a question it is passed...
The answer is already given, but with the registration
it is passed...
The task is not clear, moreover, it is the multiple user task, or not... Describe the task for it is passed...
A little adds clearness
From what you decided, what bypass in a cycle  will be faster, what two requests?

I solved it, because assumed that each time to open additional request longer than to ask at already opened any property, actually about it and a question, suddenly already all is invented for a long time, and I am engaged in nonsense of this (I remind that I the terrible layman in a question of programming and on existence of many things only guess!).
If to pass to a reality I want to solve the task with adding from  tables of records, and to single line  - four lines  with different parameters. I need to unite them something, therefore I have a field long in which I simply type digits (accordingly, to all records added in  on one of  identical number is put). And just the task in that to define a maximum in this column at the moment of adding.

17

Re: Maximum from Recordset

Akina wrote:

it is passed...
And it is stupid to look, how many it is as much as possible added, and  it is so much to a variable in the end of the next coil of a cycle instead of once again climbing in the table - not? Or you suppose, what it suddenly yes does not register?

It is not eliminated:D the table-source original
And still other user can launch the similar program on the same table but with the data. It is improbable, but it is not eliminated.

18

Re: Maximum from Recordset

But if so it turns out, what you and itself not in course that you add? And whether you add  or the counterpart together with the neighbor? A couple at you there the wrong... Here over physics of process and ideology of its handling to think, instead of about that as unreasoned something to implement in the code.

19

Re: Maximum from Recordset

Akina wrote:

But if so it turns out, what you and itself not in course that you add? And whether you add  or the counterpart together with the neighbor? A couple at you there the wrong... Here over physics of process and ideology of its handling to think, instead of about that as unreasoned something to implement in the code.

It really brothel, but is better than anything while I can not make)
All sympathizing and participating thanks!

20

Re: Maximum from Recordset

MokeevP;
From your code  the following: to add 3 (N records) records in the table with field value YEARNUM
The first-max (YEARNUM) +1
The second-max (YEARNUM) - 1
The third-max (YEARNUM) + 2
N-max (YEARNUM) + N
Can you  explain what data are available also WHAT EXACTLY want

21

Re: Maximum from Recordset

sdku wrote:

MokeevP;
From your code  the following: to add 3 (N records) records in the table with field value YEARNUM
The first-max (YEARNUM) +1
The second-max (YEARNUM) - 1
The third-max (YEARNUM) + 2
N-max (YEARNUM) + N
Can you  explain what data are available also WHAT EXACTLY want

The correct question.
If it is really such "request" a kitchen garden to fence with  it is absolutely not necessary, and simply to launch an insertion:

INSERT INTO yourtable (YEARNUM)
SELECT t. MaxYEARNUM + Ch.ch FROM
(SELECT MAX (YEARNUM) AS MaxYEARNUM FROM yourtable) AS t
INNER JOIN (SELECT 1 AS Ch UNION SELECT-1 UNION SELECT-2) AS ch ON 1 = 1

Aktses  it is not assured that, but idea I think is clear.

22

Re: Maximum from Recordset

sdku wrote:

MokeevP;
From your code  the following: to add 3 (N records) records in the table with field value YEARNUM
The first-max (YEARNUM) +1
The second-max (YEARNUM) - 1
The third-max (YEARNUM) + 2
N-max (YEARNUM) + N
Can you  explain what data are available also WHAT EXACTLY want

SandalTree wrote:

the Correct question.
If it is really such "request" a kitchen garden to fence with  it is absolutely not necessary, and simply to launch an insertion:

INSERT INTO yourtable (YEARNUM)
SELECT t. MaxYEARNUM + Ch.ch FROM
(SELECT MAX (YEARNUM) AS MaxYEARNUM FROM yourtable) AS t
INNER JOIN (SELECT 1 AS Ch UNION SELECT-1 UNION SELECT-2) AS ch ON 1 = 1

Aktses  it is not assured that, but idea I think is clear.

sdku, SandalTree;
Thanks for attention to my problem
This example unsuccessful, it as though spherical in vacuum and to my DB has no relation. Whether to me was the question is interesting it is possible  take such information from object.
I will remember your variant, almost that that is necessary)

23

Re: Maximum from Recordset

Whether

MokeevP wrote:

To me was the question is interesting it is possible  take such information from object.

Well, so to sort  in "the necessary direction" and to "take" smile

Sub test ()
Dim rs As DAO.Recordset
Set rs = CurrentDb. OpenRecordset ("select * from T")
rs. Sort = "txt desc"
Debug. Print rs. OpenRecordset. Fields ("txt")
rs. Sort = "txt"
Debug. Print rs. OpenRecordset. Fields ("txt")
End Sub

24

Re: Maximum from Recordset

court wrote:

it is passed...
Well, so to sort  in "the necessary direction" and to "take" smile

Sub test ()
Dim rs As DAO.Recordset
Set rs = CurrentDb. OpenRecordset ("select * from T")
rs. Sort = "txt desc"
Debug. Print rs. OpenRecordset. Fields ("txt")
rs. Sort = "txt"
Debug. Print rs. OpenRecordset. Fields ("txt")
End Sub

HERE THIS THAT THAT IS NECESSARY!:DD
Thanks!
Then other question, on high-speed performance it is worse/is better discovery of other request?

25

Re: Maximum from Recordset

_, validly, thanks for council)