Hello, I have a parts db that I am trying to send a request to re-order email when the parts quantity is low. From the form the user opens a sub form to edit the parts details and if it needs to be ordered the can hit the button and it will send out the email.
I am trying to put the item name from the Item field and put it in the email subject and then pull the Item, Part Number and Quantity to use in the emails body. I have been scouring the web for possible answers, the email gets sent but only with the text for the code. I have tried using Dlookup and SQL expressions but I don't have a where criteria, I just want to pull from the current record that is opened in the sub form.
Parts is the Table.
Item, PartNumber and Quantity are the fields/columns
This will be sent to same person everytime, and just need a simple email for them to see to re-order more parts.
It has changed numerous times, but this is where I currently am at, thanks in advance for your help.
I am trying to put the item name from the Item field and put it in the email subject and then pull the Item, Part Number and Quantity to use in the emails body. I have been scouring the web for possible answers, the email gets sent but only with the text for the code. I have tried using Dlookup and SQL expressions but I don't have a where criteria, I just want to pull from the current record that is opened in the sub form.
Parts is the Table.
Item, PartNumber and Quantity are the fields/columns
Code:
Private Sub ReOrderEmail_Click()
Dim olApp As Object
Dim objMail As Object
Dim Mailsql As String
Dim Subsql As String
' Puts date in reordered date field
Me.txtReOrderedDate = Date
Dim rs As DAO.Recordset
Subsql = CurrentDb.OpenRecordset("SELECT Item FROM Parts")
Mailsql = CurrentDb.OpenRecordset("SELECT Item,Quantity FROM Parts")
'Sends Email
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err Then
Set olApp = CreateObject("Outlook.Application")
End If
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.To = "address@company.com"
.Subject = "Please Reorder" & Subsql
.Body = Mailsql
.send
End With
MsgBox "The email has been sent."
rs.Close
Set rs = Nothing
End Sub
It has changed numerous times, but this is where I currently am at, thanks in advance for your help.
Comment