Hello everyone,
I'm currently working on a project to automatize the ordering process of samples and to manage an material library.
Architecture:
Availability status tables, linked to exported data info tables (.xls) which also hold data like location and also the suppliers, so there are several records for each product, each for a different supplier. The supplier contact info is in another table.
Also for the ordering process, I have a "OrderedItems" table, which lists every item ordered and I'm planning to link a "Orders" table, which summarizes orders, if there is more than one item ordered per supplier.
That already brings me to my problem:
Whereas I was able to manage to create everything for a single item order process, I'm not able to think of a suitable vba/macro solution, when there is a whole list of different items to order.
Right now, the single ordering process is structured like that:
Input (Material Number) -> Order Form with all different suppliers as different records and "Order now" button. Function appends selected Item to OrderedItems list and generates mail to the supplier, open to review and send. For assigning a order number I used the
function, as every order only contains one item. The mail generation is afterwards done by pulling things like receiver info, supplier info (mail, name,...) out of the OrderedItems table and the generation of a Outlook.Application.
That already works nice
However, when it comes to automating the process, if there are several items to be ordered, I'm hitting my conceptional vba limits
So what I'm trying to do is:
-Add Items to OrderListTEMP by "collect orders"-button, not directly order it (already done)
On the click of another button, that list should be further progressed:
-sort by SupplierName
-assign only one order number per supplier order, not per ordered Item
-prepare one mail per supplier, of course this time not only mentioning one but several items
-append that order to OrderedItems table, delete it out of the OrderListTemp, maybe also add that order number to the "Orders" table
So I'm relatively new to coding:
I know that I'm going to need a loop going through the records, assigning one number (+1 to last used one) per supplier, collecting the different numbers in one string and inserting that string into the mail instead of the single number. After that do the same thing with the next supplier until none is left. Afterwards delete the records out of the temp-table (or do that after every set of records?)
However, I'm not able to put that into code
Any help, how to do something like that would be greatly appreciated.
I'm also attaching the current "single order"-mail code as I use it
Thanks in advance,
Tobi
P.S: every "mail" had an "e" in front of it, however I had to delete that for submitting the post as I'm not allowed to include email addresses with <10 posts 
I'm currently working on a project to automatize the ordering process of samples and to manage an material library.
Architecture:
Availability status tables, linked to exported data info tables (.xls) which also hold data like location and also the suppliers, so there are several records for each product, each for a different supplier. The supplier contact info is in another table.
Also for the ordering process, I have a "OrderedItems" table, which lists every item ordered and I'm planning to link a "Orders" table, which summarizes orders, if there is more than one item ordered per supplier.
That already brings me to my problem:
Whereas I was able to manage to create everything for a single item order process, I'm not able to think of a suitable vba/macro solution, when there is a whole list of different items to order.
Right now, the single ordering process is structured like that:
Input (Material Number) -> Order Form with all different suppliers as different records and "Order now" button. Function appends selected Item to OrderedItems list and generates mail to the supplier, open to review and send. For assigning a order number I used the
Code:
OrderNum = Nz(DMax("[OrderNum]", "OrderedItems"), 0) + 1
That already works nice

However, when it comes to automating the process, if there are several items to be ordered, I'm hitting my conceptional vba limits

So what I'm trying to do is:
-Add Items to OrderListTEMP by "collect orders"-button, not directly order it (already done)
On the click of another button, that list should be further progressed:
-sort by SupplierName
-assign only one order number per supplier order, not per ordered Item
-prepare one mail per supplier, of course this time not only mentioning one but several items
-append that order to OrderedItems table, delete it out of the OrderListTemp, maybe also add that order number to the "Orders" table
So I'm relatively new to coding:
I know that I'm going to need a loop going through the records, assigning one number (+1 to last used one) per supplier, collecting the different numbers in one string and inserting that string into the mail instead of the single number. After that do the same thing with the next supplier until none is left. Afterwards delete the records out of the temp-table (or do that after every set of records?)
However, I'm not able to put that into code

Any help, how to do something like that would be greatly appreciated.
I'm also attaching the current "single order"-mail code as I use it
Thanks in advance,
Tobi
Code:
Public Function sendmailF()
Dim strmail, strBody1, strBody2, strBody3, strCC, strMatID, strName, strCountry, strMerchInCharge, strBuyer, strOrderNum As String
Dim objOutlook As Outlook.Application
Dim objmail As Outlook.MailItem
'Creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.Application")
Set objmail = objOutlook.CreateItem(olMailItem)
'Creates strings
strmail = [Forms]![SingleOrder_F]![mail]
strMerchInCharge = [Forms]![SingleOrder_F]![Merch]
strMatID = [Forms]![SingleOrder_F]![Ref_num]
strName = [Forms]![SingleOrder_F]![Name]
strCountry = [Forms]![SingleOrder_F]![Country]
strBuyer = [Forms]![MaterialInput]![UserName]
strOrderNum = [Forms]![MaterialInput]![OrderNum]
'strBody definitions (contain confidential info, therefore I'm not gonna include them here)
'Creates and sends mail
With objmail
.To = strmail
.CC = strMerchInCharge
.Subject = "Fabric Sample Order #" & strOrderNum & " "
.Body = strBody1 & strBody2 & strBody3
.Display
End With
Forms!MaterialInput.Form.Requery
Forms!MaterialInput.Form.Refresh
'Set objmail = Nothing
Exit Function
