B
Beginner
Hi!
I'm testing the following thing because I'm interested in why it works.
The situation I'm starting with:
I have a table with 3 fields and some data in it. The fields are: Id
(double), Name (text) and Calc (double). I put data into the table like this
(with my two hands):
Id Name Calc
8 Eight
5 Five
2 Two ... etc, id:s are from 1 to 10. Into the field Calc I don't put
anything.
Then I make a query, select * from the table I just filled with stuff. I
order it desc by Id. The query is named MyQuery.
Then I run the following code:
Sub TestingValues()
Dim rs As New ADODB.Recordset
rs.Open "MyQuery", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Dim k As Double
Do While rs.EOF = False
k = rs![Id]
rs![Calc] = k
rs.MoveNext
Loop
End Sub
So I put values into the Calc-fied, and the value I put is always the same
as the Id in the record I'm processing. Notice that I am processing the query
in my code.
So, in this thing I have a table which has 10 records. I have a query in
which I sort the records desc by Id and code which puts data into the Calc
field in the query.
Now. When I open the query, it is sorted desc (as it should be) and the
walues are correct (Id 1 has Calc value 1 and so on). When I open the table
it is sorted asc by Id and the values are correct (Id 2 has Calc value 2 and
so on).
My first question is:
Why does this work correctly?
And second one:
Can I rely on it to work like this even with huge amount of data and with
multiple calculated fields?
- Beginner -
I'm testing the following thing because I'm interested in why it works.
The situation I'm starting with:
I have a table with 3 fields and some data in it. The fields are: Id
(double), Name (text) and Calc (double). I put data into the table like this
(with my two hands):
Id Name Calc
8 Eight
5 Five
2 Two ... etc, id:s are from 1 to 10. Into the field Calc I don't put
anything.
Then I make a query, select * from the table I just filled with stuff. I
order it desc by Id. The query is named MyQuery.
Then I run the following code:
Sub TestingValues()
Dim rs As New ADODB.Recordset
rs.Open "MyQuery", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
Dim k As Double
Do While rs.EOF = False
k = rs![Id]
rs![Calc] = k
rs.MoveNext
Loop
End Sub
So I put values into the Calc-fied, and the value I put is always the same
as the Id in the record I'm processing. Notice that I am processing the query
in my code.
So, in this thing I have a table which has 10 records. I have a query in
which I sort the records desc by Id and code which puts data into the Calc
field in the query.
Now. When I open the query, it is sorted desc (as it should be) and the
walues are correct (Id 1 has Calc value 1 and so on). When I open the table
it is sorted asc by Id and the values are correct (Id 2 has Calc value 2 and
so on).
My first question is:
Why does this work correctly?
And second one:
Can I rely on it to work like this even with huge amount of data and with
multiple calculated fields?
- Beginner -