Recordset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with a range of dates. I would like to select the minimum
date and assigned it to a label on a report when the report is opened.

the code I currently have is giving me a type mismatch on the :set myset =
....

dim mydb as database
dim sqlquery as string
dim myset as recordset

set mydb =dbengine.workspaces(0).databases(0)
sqlquery ="select min([startdate]) from perioddates"
set myset =mydb.openrecordset(sqlquery)

and I am assuming that I can then
use mydate = myset![startdate]

and assign the variable mydate to the label on the report.

Help!!

Thanks
 
If the field is label you should use

if not myset.eof then
me.mydate.caption = nz(myset![startdate],date())
end if
 
Which line of code errored out?

My guess is that you need to add the DAO Library into the References
collection of your database. Also, if you have both ADO Library and DAO
Library, you need to disambigutate the Recordset declaration like:

Dim myset As DAO.Recordset
 
try that assuming that the table exist in your current DB
dim mydb as database
dim sqlquery as string
dim myset as recordset

set mydb =codedb
sqlquery ="select min([startdate]) as MinDate from perioddates"
set myset =mydb.openrecordset(sqlquery)
if not myset.eof then
me.mydate.caption = myset![MinDate]
end if
 
Back
Top