Query returning results twice

B

Brian

I have a pass-through SELECT statement that runs against a sequence generator
in a DB2 database via an ODBC connection. The result should be incremented by
1 each time the query is run.

When I run my query manually (i.e. double-click on the query), it correctly
increments the value by one and returns the incremented value to me. However,
when I assign the returned result to a variable in VBA or call that query
from another query as follows,

varName = DLookup("[FieldName]","[PassThroughQueryName]")

the returned value increments by 2. It appears that the query hits the ODBC
connection once when run manually, but twice when the query is called from
VBA or another query.

Does the domain aggregate call (DLookup, DFirst, etc.) result in the query
actually hitting the database twice, or is it something else? The result is
the same whether I use DLookup or DFirst. If so, is there another way to get
my variable assigned to the results of the pass-through query that will not
result in the duplicate call?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top