DCount or OpenRecordset what is better (1 Viewer)

smig

Registered User.
Local time
Today, 06:06
Joined
Nov 25, 2009
Messages
2,209
Are you basing that on the test in post #16?

nope. that's why I wrote "I imagine" ;)
only on the fact it will bring a result once it find the first (random) accurance, and as I look for the Key any record must have it.
 

vbaInet

AWF VIP
Local time
Today, 04:06
Joined
Jan 22, 2010
Messages
26,374
nope. that's why I wrote "I imagine" ;)
only on the fact it will bring a result once it find the first (random) accurance, and as I look for the Key any record must have it.
Give it a quick test and you will be suprised what the result is ;)
 

MarkK

bit cruncher
Local time
Yesterday, 20:06
Joined
Mar 17, 2004
Messages
8,181
Another thing worth mentioning in this discussion of DomainAggregate vs Recordset:
The domain aggregate functions provided by the Access.Application object, so DLookup(), DCount(), etc... are never aware of transactions, as demonstrated...
Code:
   CurrentDb.Execute "UPDATE MyTable SET Field1 = 0" [COLOR="Green"]'sets all field1 to 0[/COLOR]
   Debug.Print DLookup("Field1", "MyTable")          [COLOR="Green"]'displays 0 in the immediate pane[/COLOR]

   DBEngine(0).BeginTrans
   CurrentDb.Execute "UPDATE MyTable SET Field1 = 1" [COLOR="Green"]'set all field1 to 1[/COLOR]
   Debug.Print DLookup("Field1", "MyTable")         [COLOR="Green"] 'still displays 0 in the immediate pane[/COLOR]

   DBEngine(0).CommitTrans
   Debug.Print DLookup("Field1", "MyTable")          [COLOR="Green"]'displays 1 in the immediate pane[/COLOR]
I spent a long time once finding this out.
 

smig

Registered User.
Local time
Today, 06:06
Joined
Nov 25, 2009
Messages
2,209
I think this is because the CommitTrans is what close the transactions, and realy do it.

it's like when you run an update query, the query run for some time and at the end you get the message "Do you want to update ...." only after you click "Yes" data is realy writen and query ends.
 

Users who are viewing this thread

Top Bottom