roxannep
Technical User
- Jun 20, 2000
- 69
Here is my current code to run a SendObject routine that sends individual emails to people who have placed and paid for orders on Ebay with our company. <br><br>Originally, when I designed this, I put the actual query string in and put in exact dates as the criteria in the SQL string, but now, I want it to reference a form that allows input from the user (they choose the date range), then have that be the criteria for the query records return. How can I do that? <br><br>Current code:<br><br>Private Sub Command17_Click()<br>Dim db As Database, rst As Recordset, SQL As String<br>Dim a As Integer, EmailInfo As String<br> <br>Set db = CurrentDb<br>SQL = "SELECT Contacts.EmailName, Transactions.ShipDate, Contacts.Name, Contacts.Address, Contacts.City, Contacts.StateorProvince, Contacts.PostalCode, Transactions.Item, Transactions.Title, Transactions.SerialNo FROM Contacts INNER JOIN Transactions ON Contacts.ContactID = Transactions.ContactID WHERE (((Transactions.ShipDate) Between #1/1/2000# And #1/2/2000#));"<br>Set rst = db.OpenRecordset(SQL)<br>rst.MoveLast<br>rst.MoveFirst<br> <br>For a = 1 To rst.RecordCount<br>' Infomation could also change here<br> EmailInfo = "Shipping Confirmation for "<br> EmailInfo = EmailInfo & rst![Title] & ", Ebay Confirmation No. " & rst![Item] & ". "<br> EmailInfo = EmailInfo & "The product you ordered through E-Bay was shipped on " & rst![ShipDate]<br> EmailInfo = EmailInfo & " to " & rst![Name] & " at "<br> EmailInfo = EmailInfo & rst![Address] & ", " & rst![City] & ", " & rst![StateorProvince] & " " & rst![PostalCode]<br> <br>DoCmd.SendObject acSendNoObject, " ", acFormatTXT, rst!EmailName, , , "Shipping Confirmation", EmailInfo, False, " "<br><br>rst.MoveNext<br>Next<br>End Sub