JSalle0826
Registered User.
- Local time
- , 19:40
- Joined
- Mar 7, 2012
- Messages
- 14
Hello all,
I'm completely new to the forum and to VBA. I have an Access database that I've built and been using at my company for years, and over these years I've managed to do almost anything to not use VBA because it is a complete foreign language to me.
I need some help with a form and subform that I've created where users create a supply order request for a customer and when they complete the request, they click on the "Add Record" button and I want an email to be sent to select parties that I've chosen.
Based on some internet searches, so far everything is working perfectly of what I've built/tweaked, the final hurdle for me is that I cannot get the details of the request contained in the subform to list in the email.
I've looked all over and cannot find anything...I've tried Loops and RecordsetClone, but as I've stated earlier, cannot understand it nor get it to work. If anyone can provide me any help, I would be extremely grateful.
Here is my code thus far and that I'm having trouble with the code in red...
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Set fso = New FileSystemObject
Subjectline$ = "SUPPLY ORDER - " & [Forms]![Supply Requests]![Client ID].Column(1)
MyBodyText = "A new supply request has been entered into the database for fulfillment by " & [Forms]![Supply Requests]![Order Requestor].Column(1) & "!" & vbNewLine & vbNewLine & "Please click on the Incomplete Supply Orders button in the database to fulfill."
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Order Information:"
MyBodyText = MyBodyText & vbNewLine & vbNewLine & [Forms]![Supply Requests]![Client ID].Column(1)
MyBodyText = MyBodyText & vbNewLine & [Forms]![Supply Requests]![Address Line 1]
MyBodyText = MyBodyText & vbNewLine & [Forms]![Supply Requests]![Text35]
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Notes: " & [Forms]![Supply Requests]![Order notes]
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Order Specifics:"
MyBodyText = MyBodyText & vbNewLine & [Forms]![Supply Requests]![Supply Request Details Subform]![Quantity] & " " & [Forms]![Supply Requests]![Supply Request Details Subform]![Product ID].Column(1)
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Thank you!"
I cannot get it to cycle through all the records. I've tried loops and they don't work for me....
Currently the code, as displayed will send me the first item in the details form only...
Again, any help anyone could provide would be much appreciated.
Thanks.
Jeff
I'm completely new to the forum and to VBA. I have an Access database that I've built and been using at my company for years, and over these years I've managed to do almost anything to not use VBA because it is a complete foreign language to me.
I need some help with a form and subform that I've created where users create a supply order request for a customer and when they complete the request, they click on the "Add Record" button and I want an email to be sent to select parties that I've chosen.
Based on some internet searches, so far everything is working perfectly of what I've built/tweaked, the final hurdle for me is that I cannot get the details of the request contained in the subform to list in the email.
I've looked all over and cannot find anything...I've tried Loops and RecordsetClone, but as I've stated earlier, cannot understand it nor get it to work. If anyone can provide me any help, I would be extremely grateful.
Here is my code thus far and that I'm having trouble with the code in red...
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Set fso = New FileSystemObject
Subjectline$ = "SUPPLY ORDER - " & [Forms]![Supply Requests]![Client ID].Column(1)
MyBodyText = "A new supply request has been entered into the database for fulfillment by " & [Forms]![Supply Requests]![Order Requestor].Column(1) & "!" & vbNewLine & vbNewLine & "Please click on the Incomplete Supply Orders button in the database to fulfill."
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Order Information:"
MyBodyText = MyBodyText & vbNewLine & vbNewLine & [Forms]![Supply Requests]![Client ID].Column(1)
MyBodyText = MyBodyText & vbNewLine & [Forms]![Supply Requests]![Address Line 1]
MyBodyText = MyBodyText & vbNewLine & [Forms]![Supply Requests]![Text35]
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Notes: " & [Forms]![Supply Requests]![Order notes]
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Order Specifics:"
MyBodyText = MyBodyText & vbNewLine & [Forms]![Supply Requests]![Supply Request Details Subform]![Quantity] & " " & [Forms]![Supply Requests]![Supply Request Details Subform]![Product ID].Column(1)
MyBodyText = MyBodyText & vbNewLine & vbNewLine & "Thank you!"
I cannot get it to cycle through all the records. I've tried loops and they don't work for me....
Currently the code, as displayed will send me the first item in the details form only...
Again, any help anyone could provide would be much appreciated.
Thanks.
Jeff