quick simple question

I

ifoundgoldbug

Greetings once again

I am trying to automate our Preventative maintence program. My boss
requested that the PM's for the week be automatically e-mailed to him
every monday. so I need to store a date for reference the first record
of field Email sent. to reference against Date().

I was thinking of doing a check like

<pseudo code>

if (Date() - LastEmail) >6 OR date() = VbMonday then

send e-mail
LastEmail = Date()


End if

</pseudo code>


as always your help is appreciated
 
I

ifoundgoldbug

thanks for the help. that looks a lot cleaner.

but how do can I access just the first record of field LastEmail using
code?

thanks again for your help

Gold Bug
 
S

Stefan Hoffmann

hi,

but how do can I access just the first record of field LastEmail using
code?
Guess you have table PM(ID, ..., LastSent:Date/Time).

Dim rs As ADODB.Recordset

Set rs = New ADODB.Recordset

rs.Open "SELECT TOP 1 * FROM PM ORDER BY ID ASC", _
CurrentProject.Connection, adOpenForwardOnly, adLockOptimistic
Debug.? rs![LastSent]
rs.Close

Set rs = Nothing


or

rs.Open "SELECT * FROM PM " & _
"WHERE (Date()-LastSent)>6 " & _
"AND DatePart('w', ExecutionDate) = DatePart('w', Date())", _
CurrentProject.Connection, adOpenDynamic, adLockOptimistic
Do While Not rs.Eof
'....
rs![LastSent] = Date()
rs.Update
rs.MoveNext
Loop
rs.Close


mfG
--> stefan <--
 

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