DMax()

G

Guest

How can I use DMax() in a querie to get the highest no in a recordset and
sore it in a variable?

Gad
 
G

Guest

You shouldn't need to use a query in this case, and, in fact, you should
seriously avoid using any domain aggregrate functions in queries, because
they can be really slow. Since you want to populate a variable, you'll need
to do this in code, so you might as well use VBA code to determine your max.
value as well.

An example that comes to mind of using DMax in VBA code to determine the
next highest number can be found at Roger's Access Library:

http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb

As long as the criteria field is properly indexed, you should not suffer the
same performance hit that you would if you used a domain aggregrate function
in a query.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
 

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