#### Topic: Comparing of a current line from the previous

Good afternoon!
There is a request which forms the data with two columns Name and M:
Name M
1
1
1
1
221
221
221
221
3234
3234
3234
434
434
434
..
It is necessary in the field M to write down value from 1 to 3 in sequence and so up to the end  that that would turn out that type:
Name M
1 1
1 1
1 1
1 1
221 2
221 2
221 2
221 2
3234 3
3234 3
3234 3
434 1
434 1
434 1
..
I so understand that it is necessary to compare value in the lines across the field Name and if value exchanged, to write down in the field M the necessary
Number. Prompt please as it to implement in request.

#### Re: Comparing of a current line from the previous

If an initial data set - request within the limits of request MS Access the decision of this task is rather problematic. Here there are no ranging functions.

#### Re: Comparing of a current line from the previous

Aziz why in your example for three groups numbering goes with rise, and for 434 again 1, instead of 4?
Similar tasks dare application of own function in which the received value is compared to the saved previous value by result leaves or changes the previous value of the counter.
For what purpose such exotic is necessary to you?

#### Re: Comparing of a current line from the previous

Akina;
And to create the table and to write down  request in it? It can help?

#### Re: Comparing of a current line from the previous

Anatoly (Kiev);
Exotic is an exact determination)).
I will try to explain:
There is a request which produces  with fields (Object, the equipment Name on object, January, February, and . till December.)
In the field "Object" - the name of object of service
In the field "the equipment Name on object" - the equipment name on the given object a subject ..
In fields "January". "February" etc. - the name of a type led . (-1, -2, -3).
So it turns out that on months kol-in led THAT on object strongly differs (In January for example 0, and in March can be 30). And if it is a lot of objects, in on some months THAT will not be led (for example January), and on some it is necessary to lead THAT under all list of the equipment (for example March). Especially loaded months - March, June, September, December
Therefore decided to add one more field "M" on which I will use the operator MOD ("Field M", 3) and depending on result to bring the necessary value in fields "January". "February" etc. and thus it to turn out to arrange loading on months.
Here is how that so.
I hope a smog

#### Re: Comparing of a current line from the previous

Aziz wrote:

And to create the table and to write down  request in it?

The static table is simple for opening as  and to renumber a VBA-code.
But there is a dirty trick - at you in an example the data is explicitly sorted, and to a certain sign which did not get to a total data set. That is why there is no warranty that in  the output order  will not be changed. It is necessary to add a sign which corresponding ORDER BY allows to save a sequence of records in the static table.

#### Re: Comparing of a current line from the previous

Aziz wrote:

.... In the field "the equipment Name on object" - the equipment name on the given object a subject ....

I Hesitate : as it is defined is subject or is not present-after all there should be any periods, norms, k-in cycles, etc. (and here about it are not present words) If periodicity THAT is defined "when it would be desirable" a level of automation of the registration THAT cannot be high (that you and try to do)

#### Re: Comparing of a current line from the previous

sdku;
It agree with you, is both periods and norms. Did not begin to write about it. An essence of a question that not in it...
I will try to clear up.
There is a reference manual THAT in which the equipment and its periodicity THAT in a year, where -1 once a month, -2 once a quarter, -3 once a year, for example is specified:
THAT of the electronic sensor -1 8 -2 3 -3 1
THAT of a regulator of temperature -1 2 -2 2
THAT of the electronic thermotransformer. -1 11 -2 1
THAT of the temperature sensor -1 8 -2 3 -3 1
Kol-in THAT for the equipment it is defined by the reference manual, and type 8-3-1 dial-up, 2-2, 11-2 it is etc. restricted.
I made request and scattered all possible variants on months.
Max (Switch (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1")) AS January,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", Null)) AS February,
Max (Switch (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=3) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=3) Or ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=4), "-2")) AS March,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=2) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", Null)) AS April,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", Null)) AS May,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=3) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", IIf (([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=2) Or ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=3) Or ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=4), "-2", Null))) AS June,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", Null)) AS July,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", Null)) AS August,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=3) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", IIf (([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=3) Or ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=4), "-2", Null))) AS September,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=2) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", Null)) AS October,
Max (IIf (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=8) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=10) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=11) Or ([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", Null)) AS November,
Max (Switch (([Request of software THAT].VidTO = "-1" And [Request of software THAT].KolvoTO=12), "-1", ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=1) Or ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=2) Or ([Request of software THAT].VidTO = "-2" And [Request of software THAT].KolvoTO=4), "-2", ([Request of software THAT].VidTO = "-3" And [Request of software THAT].KolvoTO=1), "-3")) AS December
And basically it suits me, but on some months (March, June, September, December) kol-in THAT which need to be led, grows in times in relation to other months. Therefore the idea also was born will add a field "M" which to consist of values from 1 to 3. And using the operator MOD ("Field M", 3) I can generate and arrange anew loading on months.
I hope a smog all explain.

#### Re: Comparing of a current line from the previous

Aziz;
And why not to add periods (periods) to commissioning date, and the received value will be, hosh-not , rigid, not subject to change, date of carrying out THAT

#### Re: Comparing of a current line from the previous

sdku;
As a variant. But then it is necessary to add in the table a field "date of commissioning of object", and it would be desirable all to make at request level.
I so understand that the task as I would like is not implemented. Therefore I see its decision 1. To write down all in the table. 2. All idea to implement on VB.
Can eat judgements still?

#### Re: Comparing of a current line from the previous

Question: if THAT on periodicity once a year and I lead it 30.12.10 and whether true the statement that it 10.01.11-will be led in 10 and 11 year with periodicity observance (you try to make it)

#### Re: Comparing of a current line from the previous

sdku;
Yes, truly.
But if my idea to turn out to implement, periodicity THAT will be observed. The idea that is banal - to divide all objects into three groups and to shift initial date performance THAT on each group of objects. I.e.:
1 group - all THAT which initially got on (March, June, September, December) month, I transport in January, April, July, September.
2 group - all THAT which initially got on (March, June, September, December) month, I transport in February, May, August, November.
3 group - all THAT which initially got on (March, June, September, December) month, remains same month.

#### Re: Comparing of a current line from the previous

Interval 11. An interval almost 2 years
30.12.2010 10.01.11. 12/31/2012
And so why lifts fall ))
(once a year can in a year, instead of?)

#### Re: Comparing of a current line from the previous

And that hinders to group Name in the temporary table.
In the same place to enumerate the second column 1-2-3
And then from it to fill M in the underlying table?
Like all it is elementary...

#### Re: Comparing of a current line from the previous

982183;
And can show on an example?

#### Re: Comparing of a current line from the previous

982183;
Thanks for the help. All turned out.

#### Re: Comparing of a current line from the previous

Something through integer the remainder of division recno () is impossible to me.
Only through case

#### Re: Comparing of a current line from the previous

Aziz wrote:

And if it is a lot of objects in on some months THAT it will not be led (for example January), and on some it is necessary to lead THAT under all list of the equipment (for example March). Especially loaded months - March, June, September, December

I am familiar with the similar task (at first , then )
I started with
--The between-repairs period (at me were also  and )
--Structures of a cycle of a cycle of surveys of type 1333323333233331
--Date and type of the last survey/repair
Found in what place of a cycle there is a given equipment and appropriated schedulable surveys
Therefore so it is explicit March, June, September, December were not selected

#### Re: Comparing of a current line from the previous

Aziz;
To tell the truth, I did not understand idea of passage on a cycle of surveys

``````Max (Switch (
(w. VidTO = "-1" And w. KolvoTO=8)
Or (w. VidTO = "-1" And w. KolvoTO=10)
Or (w. VidTO = "-1" And w. KolvoTO=11)
Or (w. VidTO = "-1" And w. KolvoTO=12), "-1")) AS January,
Max (IIf ((w. VidTO = "-1" And w. KolvoTO=8)
Or (w. VidTO = "-1" And w. KolvoTO=10)
Or (w. VidTO = "-1" And w. KolvoTO=11)
Or (w. VidTO = "-1" And w. KolvoTO=12), "-1", Null)) AS February,
Max (Switch ((w. VidTO = "-1" And w. KolvoTO=3)
Or (w. VidTO = "-1" And w. KolvoTO=10)
Or (w. VidTO = "-1" And w. KolvoTO=11)
Or (w. VidTO = "-1" And w. KolvoTO=12), "-1", (w. VidTO = "-2" And w. KolvoTO=3)
Or (w. VidTO = "-2" And w. KolvoTO=4), "-2")) AS March;
.....``````