473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

why is my loop not picking up the next value?

I know my loop is working because the counter is working and I am getting three emails. The problem is the value from the table is staying with row 1. I do not know why the row 2 value is not being loaded into the varible and emailed to me. The value getting loaded into TxtSubject is staying with the value of row 1 not getting to the value of row 2, etc.

Please review the below code.

Thank you very much. Russ

Expand|Select|Wrap|Line Numbers
  1. Private Sub MFNDTEMAILBUTTON_Click()
  2.  
  3. '==The first part prepares a table that is equal to a record set from the query to be loop through
  4.  
  5. Dim db As DAO.Database
  6. Dim rs As DAO.Recordset
  7. Dim intNumRecs As Integer
  8.  
  9. ' The query loop below
  10.  
  11. Set db = CurrentDb()
  12. intNumRecs = 0
  13. Set rs = db.OpenRecordset("Q1230NDT3RDNOTICE")
  14. While Not rs.EOF
  15.    ' do what has to be done
  16.    intNumRecs = intNumRecs + 1
  17.    rs.MoveNext
  18. Wend
  19. Set rs = Nothing
  20.  
  21. '==This section provides the configuration information for the remote SMTP server.
  22. '==Normally you will only change the server name or IP.
  23. '== the call is items are toemail fromemail subj body
  24.  
  25. Dim Txtbody1 As String
  26. Dim TxtSubject As String
  27. Dim Txtbody2 As String
  28. Dim Txtbodyall As String
  29. Dim Response As Integer
  30.  
  31. Txtbody2 = "Notice of Confidentiality: **"
  32. Txtbody1 = " Test"
  33. Txtbodyall = "Date Received - " & Txtbody1 & " - " & Txtbody2
  34. Response = MsgBox("Please confirm the emailing of " & intNumRecs & " solicitations?", vbYesNo + vbQuestion, "Send by Email?")
  35.  
  36. If Response = vbYes Then
  37.    'user answered "Yes"
  38.    intNumRecs = 0
  39.    Set rs = db.OpenRecordset("Q1230NDT3RDNOTICE")
  40.    While Not rs.EOF
  41.        ' do what has to be done
  42.        intNumRecs = intNumRecs + 1
  43.        TxtSubject = rs!IDCoName_2010TDB
  44.  
  45.        Call Xmail("Russell.neuman@lfg.com", "Russell.Neuman@lfg.com", TxtSubject, Txtbodyall)
  46.  
  47.        rs.MoveNext
  48.    Wend
  49.    Set rs = Nothing
  50.    MsgBox "The number of NDT solicitation(s) emailed was: " & intNumRecs & ".", vbOKOnly, "Confirmation...  "
  51. Else
  52.   'user answered "No"
  53.    MsgBox "This NDT was Not emailed.", vbOKOnly, "Confirmation...  "
  54. End If
  55.  
  56. End Sub
Jun 28 '11 #1
1 1528
NeoPa
32,556 Expert Mod 16PB
Russ,

Even before you changed a line of the code it was not clear what your problem was. Please explain your problem in clear, simple English. Remember, a reference which refers to something you haven't explained yet is neither clear nor simple.
Jun 28 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stewart Allen | last post by:
I'm trying to find the next value in a table that a student needs to achieve once he has already passed one grade. *tblStudents* StudentID (PK) FirstName *tblGradingDates* DateID ...
3
by: Scott Collens | last post by:
Hi there, does anyone know if it is possible to set a value in a user control and pick it up in the code behind. I'm trying to reuse the same user control and code behind for multiple pages but...
6
by: Josh Close | last post by:
I'm having a problem with a value coming out of a loop. CREATE OR REPLACE FUNCTION funmessagespermintotal() RETURNS int8 AS ' DECLARE this_rServer record; this_rSum record; this_iSum...
4
by: Diego | last post by:
Hi everybody! I wonder if there is an sql command that increases a sequence value by one and returns such a value. I would like to manage an id inside a program that connects to the database...
1
by: Deac | last post by:
I have two Access 2003 tables, one has a "Zone" and "Lot1SqFt" that changes with each record. The other table has fields (columns) for each "Zone" plus a Minimum and Maximum field and "Records"...
1
by: aaron1234nz | last post by:
I am trying to write a stored procedure add a piece of data from table2 into another table1. I thought the query was going to be easy, but I was misteken. All I am trying to achieve is: for...
2
by: anii | last post by:
Hi I'm a bit new to XML, and I was wondering if anyone could help me with my problem. I have one XML document (readings.xml) being linked to an XSLT document via JavaScript DOM, and am linking the...
1
by: pfildes | last post by:
Hi, I am pretty new to VB.net and am having trouble figuring out how to do this. I have an app that copies data from one datasource to another. I have it set to run through a for loop for...
8
by: Shila | last post by:
i am doing online meter project......there is table in my html page...in that table meter show continuesly diff values............. without resfrshing page table can take next value..... that is my...
4
by: qwedster | last post by:
Folks, How to the next value of identity(1,1) before insert? SELECT IDENT_CURRENT('ExampleTable') + IDENT_INCR('ExampleTable'); --does not work when the table is empty! USE GO
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.