Recordset

D

deodev

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
 
O

Ofer

If the field is label you should use

if not myset.eof then
me.mydate.caption = nz(myset![startdate],date())
end if
 
V

Van T. Dinh

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
 
O

Ofer

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
 

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