I am having trouble with my loop code. The code works very well. However, it only loops through 3 records and then completes without errors. I will post code below. Any help with this would be greatly appreciated.
I am using Windows 2000 with Access 2000, sending email through Outlook 2000. -
-
Private Sub Form_Load()
-
On Error GoTo Err_Form_Load
-
-
Dim rst As DAO.Recordset
-
Dim bkMark As String
-
Dim stDocName As String
-
Dim strSendTo As String
-
Dim strSubject As String
-
Dim strMessageText As String
-
-
Set rst = Me.Recordset
-
-
bkMark = rst.Bookmark
-
Me.Bookmark = bkMark
-
-
rst.MoveFirst
-
-
-
Do Until rst.EOF
-
-
stDocName = "Request for Updated PO Info EMAIL"
-
strSendTo = Me.Suppliers_EmailAddress
-
strSubject = "Wesco Distribution Shipping Update Report"
-
strMessageText = "To: " & Me.SupplierName & vbCrLf _
-
& "" & vbCrLf _
-
& "Attached is a Shipping Update Report for certain PO numbers." & vbCrLf _
-
& "" & vbCrLf _
-
& "Please review the attached report and reply back to this email with the requested information." & vbCrLf _
-
& "" & vbCrLf _
-
& "Thank you," & vbCrLf _
-
& "" & vbCrLf _
-
& "Wesco Distribution Expediting Department "
-
-
DoCmd.SendObject acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText
-
-
rst.MoveNext
-
-
Loop
-
-
rst.Close
-
-
Set rst = Nothing
-
-
DoCmd.Close acForm, "Email", acSaveYes
-
-
Exit_Form_Click:
-
Exit Sub
-
-
Err_Form_Load:
-
MsgBox Err.Description
-
Resume Exit_Form_Click
-
-
End Sub
-
-
Please help me figure this out. I am completely boggled by this.
Nick
Mar 31 '08
10 3087
Thank you for you help.
I will post my code below as a finished product for this Sub. -
-
Private Sub Form_Load()
-
On Error GoTo Err_Form_Load
-
-
Dim rst As DAO.Recordset
-
Dim bkMark As String
-
Dim stDocName As String
-
Dim strSendTo As String
-
Dim strSubject As String
-
Dim strMessageText As String
-
-
Set rst = Me.RecordsetClone
-
-
If rst.EOF Then
-
-
MsgBox "There are no Supplier Reports to Email in this Branch", vbExclamation, "No e-mail addresses"
-
-
rst.Close
-
-
Set rst = Nothing
-
-
DoCmd.Close acForm, "Email", acSaveYes
-
-
Exit Sub
-
-
End If
-
-
Do While rst.EOF = False
-
bkMark = rst.Bookmark
-
Me.Bookmark = bkMark
-
-
stDocName = "Request for Updated PO Info EMAIL"
-
strSendTo = rst![EmailAddress]
-
strSubject = "Wesco Distribution Shipping Update Report"
-
strMessageText = "To: " & rst![SupplierName] & vbCrLf _
-
& "" & vbCrLf _
-
& "C/O: " & rst![ContactName] & vbCrLf _
-
& "" & vbCrLf _
-
& "Attached is a Shipping Update Report for certain PO numbers." & vbCrLf _
-
& "" & vbCrLf _
-
& "Please review the attached report and reply back to this email with the requested information." & vbCrLf _
-
& "" & vbCrLf _
-
& "Thank you," & vbCrLf _
-
& "" & vbCrLf _
-
& "Wesco Distribution Purchasing Department "
-
-
DoCmd.SendObject acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText
-
-
rst.MoveNext
-
-
Loop
-
-
MsgBox "All emails have been sent to Suppliers", 0, "Email Complete"
-
-
rst.Close
-
-
Set rst = Nothing
-
-
DoCmd.Close acForm, "Email", acSaveYes
-
-
Exit_Form_Click:
-
Exit Sub
-
-
Err_Form_Load:
-
MsgBox Err.Description
-
Resume Exit_Form_Click
-
-
End Sub
-
-
-
Thank you again for all of your help. The forum is fantastic!!!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Tim::.. |
last post by:
Hi can someone please give me some help with this little problem I am having with the following loop
...:: CODE ::.
<
'Load XM
set xml = Server.CreateObject("Microsoft.XMLDOM"
xml.async = fals
xml.load(Server.MapPath("ProjectTEST.xml")
Dim sDate(200,100
|
by: Radu |
last post by:
Hi. It seems to be very simple, actually, but I don't know if it is
feasible in TSQL. I have a sproc which gathers in one place many calls
to different other sprocs, all of them taking a 'StoreGroupe'
parameter. I would like to add a case where if the call has NO
StoreGroupe parameter, the sproc should LOOP thru all records in table
StoreGroupeTable, read the column StoreCode, and pass that value as a
param to the other sprocs, as in:
...
|
by: MLH |
last post by:
Take a look at the code that follows. Line 110 is the beginning
of Do-Loop. Regarding line #220, I find that I'm getting Error #3021
(No Current Record) during execution of line #230. It puzzles me
as to Why? I thought if I was on last valid record of RecSet when
line #220 executes, I would be sent to process lines after line #400.
Am I wrong about that?
==> BEGIN CODE SNIPPET <===
110 Do Until RecSet.EOF
StartAnew:
|
by: lakepeir |
last post by:
Hello,
I need help with my for loop. The loop does not end. It should end
when i is one less than uBound. What happens is that when i is 1 less
than uBound, the loop continues with a weird value 5432325 (I have no
idea how this value is generated, uBound is less than 10.) and then i
is equal to zero again. Here's the code:
for (int i=0; i < uBound; i++)
for (int j=0; j < uBound2; j++)
{
|
by: David |
last post by:
Hi,
I have a form on which a user can select a checkbox against a record.
Each checkbox carries the RecordID of a product.
----------------------------------------------------------------
I am trying to print the following report:-
Details for product 1
| |
by: kwstriker299 |
last post by:
Hello All--
I am trying to loop through all the records in a table named: tbl_Scan_Index. I am using MS Access 2003. Here is my code(VBA):
Dim drawer As Integer
Dim Folder As Integer
Dim msg As String
Dim count As Integer
|
by: barmatt80 |
last post by:
I finally got my call to a stored procedure on our db2 to work. However i might have to change what the stored procedure does, if I cannot get it to work how we want. Which i would like to make it work on the sql server side, and not have to change the db2 side as that takes some time from our developers.
But this is what i want to do. I have a stored procedure that calls the db2 stored procedure to return 4 leave amounts(@Annual, @Sick,...
|
by: Prashant Pradeep |
last post by:
HI,
I have two tables WORK and EMP.
Table work has fields - CaseNo,Date_Act, Handler.
Table Emp has one field - EmpName.
My field handler should be populated automatically from my table EMP.
Let us assume there are 100 records in work and 11 records in emp,
I need a query / Macro so that 100 Cases is distributed equally among 11 emp.
|
by: Gavin Sequeira |
last post by:
Hi. I have a Main form with a Subform. My Main form generates an ID and some info is passed to the subform alongwith the ID. Lets say some changes are made to the mainform, this info is then added to the subform as a new record with the same ID (as in the main form) i.e saved as a 2nd record in my subform and will show under the main forms ID as 2 records. There are times when I have to generate the same values of the main form and capture the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |