Returning a variable from a query

  • Thread starter Thread starter Wes
  • Start date Start date
W

Wes

I have a form that needs to create a unique ID upon entry. Like a new
Sales Order Number for a new sale.

What I want to do is run a query that returns the MAX value for a field.

"SELECT MAX(SALNUM) FROM TABLE"

I can then add 1 to that number and create and a new key.

I am having a problem trying to determine how the return the result to a
variable.

strA = SELECT ...... or some such thing

I have tried to look this up in the manual (RTFM) but have not had much
luck.

Any help appreciated.

Thanks

Wes
 
Wes

Try searching on-line or at mvps.org/access for "custom autonumber".

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
Take a look at the DMAX function
Dim I as long
I = DMax("SalNum","Table")

Another way

I =CurrentDb().OpenRecordset("SELECT MAX(SALNUM) FROM Table").Fields(0)


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Back
Top