Running and using SQL Commands in VBA

S

Steven M. Britton

Ok, I have never done this before so please help me if you
can. I use a bunch of queries to take that data I need
and make an Emails table. Once I get the data into the
Emails table I want to use VBA to SELECT the data I want
then send Emails and go back on UPDATE the data in the
Table. Below is most of the code that I have, but it
sends everything right now. Thanks in advance for you
help on this.

-Steve

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
DoCmd.Minimize
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblEmails")
With rec
.MoveFirst
fax: Do Until .EOF

DoCmd.SendObject acSendNoObject, , ,
rec.BILLEMAIL, , , "The Perfect Shine", _
"Dear " & rec.FULLNAME & ":" & vbCrLf & "Your order " &
rec.Order_ID & " shipped, ok." _
, False

.MoveNext
Loop
End With

Set db = Nothing
Set rec = Nothing
Exit Sub
End Sub

So what I guess I need to add is:

SELECT tblEmails.Order_ID, tblEmails.BILLEMAIL,
tblEmails.FULLNAME, tblEmails.TypeOfShipping,
tblEmails.OrderDate, tblEmails.[1stEmailDate], tblEmails.
[1stEmailSent], tblEmails.[2ndEmailDate], tblEmails.
[2ndEmailSent]
FROM tblEmails
WHERE (((tblEmails.OrderDate)=Date()));

And after I send the Email for the orders from today, I
want to update the 1stEmainSent field with and Update
Query in this same VBA code.

Thanks again...
 
Top