roxannep
Technical User
- Jun 20, 2000
- 69
I have code set up on a button that will email an individual message with unique record information based on a query pulling information based on a date range. It works fine when the dates are actually inserted in the code. What I need to do, however, is have a form come up requesting user input for the data range, then have the query pull that information and continue with the For Next SendObject code I have already set up.<br><br>Here's what I have and where it's stuck:<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>DoCmd.OpenForm [Forms]![Ship Date Range], , , , , acDialog<br>Set db = CurrentDb<br>SQL = "SELECT Contacts.ContactID, Contacts.EmailName, Transactions.TransactionID, Transactions.Item, Transactions.Title, Transactions.ShipDate, Contacts.Name, Contacts.Address, Contacts.City, Contacts.StateorProvince, Contacts.PostalCode FROM Contacts INNER JOIN Transactions ON Contacts.ContactID = Transactions.ContactID WHERE (((Transactions.ShipDate) Between #"[Forms]![Beginning Ship Date]"# AND #"[Forms]![Ending Ship Date]"#));"<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