B
Brian
At what points does a query re-query its source?
I had an issue with an ODBC connection, attempting to use a SELECT
pass-through query to assign a value to a variable. The SELECT query, when
run against the DB2 back-end, passed back a newly-created auto-number
sequence number. It always ran twice, so that the result always skipped every
other newly-created sequence ID. That is, the query apparently fired once
(which created a new record in DB2) and then fired again, which created
another record in DB2 and correctly assigned the value of the second new
sequence ID to the variable.
I finally made wrote an append query that called the SELECT query
pass-through query as its source. In this configuration, the query fired only
once, so that only a single sequence number was generated in DB2.
Now, in another circumstance, I have been experimenting with calling a
public function from within a query.
Here is the query, which just calls a Long auto-number value from tblTest:
SELECT tblTest.ID, Test([ID]) AS Test
FROM tblTest;
Here is the function:
Public Function Test(ID As Long)
MsgBox ID
End Function
When I run the query, I get the MsgBox until the screen is filled up, then
it stops. If I navigate to another window, then back, or resize the window,
it starts over at the first record again, indicating that it is, in fact
re-querying the source, not just for the additional records not previously
displayed, but for all records from the beginning.
If I again write another INSERT query that calls the query above, none of
this happens, so it has something to do with the nature of SELECT queries and
when/how they refresh results.
Actually, based on this behavior, I have pretty much opted for recordset
loops to do these types of actions, but it left me very curious about the
nature of the requery in Access queries.
I had an issue with an ODBC connection, attempting to use a SELECT
pass-through query to assign a value to a variable. The SELECT query, when
run against the DB2 back-end, passed back a newly-created auto-number
sequence number. It always ran twice, so that the result always skipped every
other newly-created sequence ID. That is, the query apparently fired once
(which created a new record in DB2) and then fired again, which created
another record in DB2 and correctly assigned the value of the second new
sequence ID to the variable.
I finally made wrote an append query that called the SELECT query
pass-through query as its source. In this configuration, the query fired only
once, so that only a single sequence number was generated in DB2.
Now, in another circumstance, I have been experimenting with calling a
public function from within a query.
Here is the query, which just calls a Long auto-number value from tblTest:
SELECT tblTest.ID, Test([ID]) AS Test
FROM tblTest;
Here is the function:
Public Function Test(ID As Long)
MsgBox ID
End Function
When I run the query, I get the MsgBox until the screen is filled up, then
it stops. If I navigate to another window, then back, or resize the window,
it starts over at the first record again, indicating that it is, in fact
re-querying the source, not just for the additional records not previously
displayed, but for all records from the beginning.
If I again write another INSERT query that calls the query above, none of
this happens, so it has something to do with the nature of SELECT queries and
when/how they refresh results.
Actually, based on this behavior, I have pretty much opted for recordset
loops to do these types of actions, but it left me very curious about the
nature of the requery in Access queries.