Creating emails in VBA

miguel vasquez

Registered User.
Local time
Today, 23:59
Joined
Nov 11, 2002
Messages
36
I have a database that creates emails from an spreadsheet, so populate the value in each email. but the only problem is that the loop not always work. When I click the button it just goes to the last department. See below my codes and let me know if anybody can help me.

Dim Tbody As String
Dim strbody As String
Dim strbody1 As String
Dim strbody2 As String
Dim strbody3 As String
Dim strbody4 As String
Dim strbody5 As String
Dim strbody6 As String
Dim strbody7 As String
Dim strbody8 As String
Dim strbody9 As String
Dim strbody10 As String
Dim month As String

Dim strGroup As String
Dim strInvoice As String
Dim strPayAmt As String
Dim strPayBtch As String
Dim strFund As String

'Prepating my LOOP


Do While Me.Recordset.EOF = False

Tbody = ""
strbody = ""
strbody1 = ""
strbody2 = ""
strbody3 = ""
strbody4 = ""
strbody5 = ""
strbody6 = ""
strbody7 = ""
strbody8 = ""
strbody9 = ""
strbody10 = ""


strGroup = Me.Group
strInvoice = Me.Invoice
strPayAmt = Me.Transfer
strPayBtch = Me.Pmt_Batch
strFund = Me.[Fund #]
month = Me.Subject


strbody = "We have received the" + " " + month + "," + " " + "and the amount allocated to your department has been transferred into fund" & Chr(10) & Chr(13)
strbody1 = "#" + "" + strFund + " " + "Group" + " " + strGroup & Chr(10) & Chr(13) & Chr(10) & Chr(13)
strbody2 = "Professional Services has posted the amount(s) listed below to a dummy $0 charge so that monthly charges would not be affected. Please note that this activity was posted to provider Professional Services, MD within the billing area Professional Services. The details are as follows:" & Chr(10) & Chr(13) & Chr(10) & Chr(13)

strbody3 = "Group" + " " + strGroup & Chr(10) & Chr(13)
strbody4 = "Invoice #" + "" + strInvoice & Chr(10) & Chr(13)
strbody5 = "Pay Amount:" + "$" + strPayAmt & Chr(10) & Chr(13)
strbody6 = "Pmt Batch#:" + "" + strPayBtch & Chr(10) & Chr(13) & Chr(10) & Chr(13)

strbody7 = "The allocation is based on actual HIP fee-for-service payments. As such, these invoices upon which this allocation is based are paid" & Chr(10)
strbody8 = "invoices (most likely with a $0 balance). Therefore, we cannot post these payments directly to the actual invoices. However, if you need to" & Chr(10)
strbody9 = "allocate these funds to individual providers, please contact me and I can provide detail by physician as well as guidelines on how to post these payments." & Chr(10) & Chr(13) & Chr(10) & Chr(13) & Chr(10) & Chr(13)
strbody10 = "Thank you"

Tbody = strbody + strbody1 + strbody2 + strbody3 + strbody4 + strbody5 + strbody6 + strbody7 + strbody8 + strbody9 + strbody10



DoCmd.SendObject , "", "", "Miguel Vasquez", "", "", month, Tbody, True, ""
Me.Recordset.MoveNext

Loop
End Sub
 
Where is the code where the recordset is created? If you are going through the recordset prior to this code, you might need a recordset.movefirst statement
 

Users who are viewing this thread

Back
Top Bottom