I have a table that holds company information for the user - eg farm name, company name, manager, phone number and email address etc. Its simply used to provide headers for reports, so that the same generic database can be used on several farms. There is only one record in this table tblfarmdetails
The second table tblorder is for orders and receipts - I currently have code that allows the user to send an order request by email to the manager, and to also send notice of receipt of goods through to the manager.
I would like the code to get the email address from the unrelated table.
Can I reference this field in the vba?
Private Sub cmdemailorder_Click()
Dim orderdate As String
Dim stafford As String
Dim item As String
Dim itemamnt As String
'**create variables for Outlook
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
orderdate = Me!orderdate
stafford = Me!Name
item = Me!item
itemamnt = Me!itemamnt
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = email address here stored in tblfarmdetails!email
.Subject = "Order Request"
.Body = stafford & " would like you to order " & item & ". Amount: " & itemamnt
.Display
End With
Set objEmail = Nothing
End Sub
The second table tblorder is for orders and receipts - I currently have code that allows the user to send an order request by email to the manager, and to also send notice of receipt of goods through to the manager.
I would like the code to get the email address from the unrelated table.
Can I reference this field in the vba?
Private Sub cmdemailorder_Click()
Dim orderdate As String
Dim stafford As String
Dim item As String
Dim itemamnt As String
'**create variables for Outlook
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
orderdate = Me!orderdate
stafford = Me!Name
item = Me!item
itemamnt = Me!itemamnt
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = email address here stored in tblfarmdetails!email
.Subject = "Order Request"
.Body = stafford & " would like you to order " & item & ". Amount: " & itemamnt
.Display
End With
Set objEmail = Nothing
End Sub