What is the best way to include an SQL statement in my VB Code and then assign the value to a variable? For example, when my form opens I would like to be able to select the max value from a table and then store it in a Global variable??
'Dao
dim strsql as string
dim rst as recordset
strsql = "select max(field) from table where criteria"
set rst=currentdb.openrecordset(strsql)
rst.movefirst
variable = rst.field(0)
rst.close
set rst = nothing
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.