473,387 Members | 1,771 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.

Form recordsetclone navigation failure!!!

78
Hello All,

I have developed a program to automatically generate and send reports based on certain criteria.

I have realized that there is a problem with its navigation. I will post the code below but basically the form opens and begins to send emails...like it is supposed to.

What I have noticed is that when it is supposed to navigate to rst.movenext it appears to be skipping records. By skipping I can visually see it going through each record on the form, but only does sendobject on random records.

Any advise on what you can see would be great. I will post code and attach DB to better assist.

Thank you in advance for your help

Nick

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. On Error GoTo Err_Form_Load
  3.  
  4. Dim rst As Object
  5. Dim bkmk As String
  6. Dim stDocName As String
  7. Dim strSendTo As String
  8. Dim strSubject As String
  9. Dim strMessageText As String
  10. Dim WAIT As Double
  11.  
  12. Set rst = Me.RecordsetClone
  13.  
  14. Me.SetFocus
  15.  
  16. If rst.RecordCount <> 0 Then
  17.     DoCmd.OpenForm "Email_Process", acNormal
  18.     Do Until rst.EOF = True
  19.         bkmk = rst.Bookmark
  20.         Me.Bookmark = bkmk
  21.  
  22.         stDocName = "Request for Updated PO Info EMAIL"
  23.         strSendTo = "nspader@wesco.com" 'rst!EmailAddress
  24.         strSubject = "Wesco Distribution Status Update Report for Branch " & rst!BR
  25.         strMessageText = "To:  " & rst!SupplierName & vbCrLf _
  26.                         & "" & vbCrLf _
  27.                         & "C/O:  " & rst!ContactName & vbCrLf _
  28.                         & "" & vbCrLf _
  29.                         & "Attached is a status update report for specific PO line items." & vbCrLf _
  30.                         & "" & vbCrLf _
  31.                         & "Please review the attached report." & vbCrLf _
  32.                         & "" & vbCrLf _
  33.                         & "PLEASE MAKE CHANGES ON THE REPORT and reply back to this email with the corrected report ATTACHED and any other required information." & vbCrLf _
  34.                         & "" & vbCrLf _
  35.                         & "If you have any questions or concerns, contact information is located on the attached report." & vbCrLf _
  36.                         & "" & vbCrLf _
  37.                         & "Thank you," & vbCrLf _
  38.                         & "" & vbCrLf _
  39.                         & "Wesco Distribution Purchasing Department "
  40.  
  41.         DoCmd.SendObject acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText, 0
  42.         WAIT = Timer
  43.         While Timer < WAIT + 1
  44.             DoEvents  'do nothing
  45.         Wend
  46.         rst.MoveNext
  47.     Loop
  48.  
  49.     rst.Close
  50.     Set rst = Nothing
  51.     bkMark = ""
  52.     DoCmd.Close acForm, "Email", acSaveYes
  53.     DoCmd.Close acForm, "Email_Process", acSaveYes
  54.     MsgBox "All emails have been sent to Suppliers", 0, "Email Complete"
  55. Else
  56.     MsgBox "There is no Email Address for Supplier's in this Branch Report File", vbExclamation, "No e-mail addresses"
  57.     rst.Close
  58.     Set rst = Nothing
  59.     DoCmd.Close acForm, "Email", acSaveYes
  60.     Exit Sub
  61. End If
  62.  
  63. Exit_Form_Click:
  64.     Exit Sub
  65. Err_Form_Load:
  66.     MsgBox Err.Description
  67.     Resume Exit_Form_Click
  68. End Sub
  69.  
Attached Files
File Type: zip Status Update Copy.zip (939.0 KB, 125 views)
Jun 18 '08 #1
10 2752
FishVal
2,653 Expert 2GB
Hello, Nick.

I would not expect this code to work at all because of the following fragment.

Expand|Select|Wrap|Line Numbers
  1. ....
  2.         WAIT = Timer
  3.         While Timer < WAIT + 1
  4.             DoEvents  'do nothing
  5.         Wend
  6.         rst.MoveNext
  7.     Loop
  8.  
  9. ....
  10.  
Regards,
Fish
Jun 18 '08 #2
mshmyob
904 Expert 512MB
I would also properly populate your recorset like so before I tried anything

Expand|Select|Wrap|Line Numbers
  1. Dim rst As Recordset
  2. ' create a recordset and populate
  3. Set rst = Me.RecordsetClone
  4.     rst.MoveLast
  5.     rst.MoveFirst
  6. ' then the rest of your code
  7.  
cheers,
Jun 18 '08 #3
nspader
78
Hello, Nick.

I would not expect this code to work at all because of the following fragment.



Regards,
Fish
Fish,

Why would the Timer make the code not work? The point of that was a previous attempt to slow the code down and allow sendobject to run before attempting to run it again.

I did try both taking out the timer portion...need the rst.Movenext to move through the recordset. And I added movelast, movefirst. I previously attempted that with no avail. Also, placing it there...wouldn't it cause an error if there are no records?

Thanx for the help, any other advice is appreciated.

Nick
Jun 18 '08 #4
nspader
78
Also, In the attached example...for branch 7848 for example it runs record 1, then goes to record 5, then goes to record 11, then goes to record 12, then says "complete". Just thought id give you exacts.
Jun 18 '08 #5
FishVal
2,653 Expert 2GB
...
Why would the Timer make the code not work? The point of that was a previous attempt to slow the code down and allow sendobject to run before attempting to run it again.
....
Sorry, didn't realize that Timer() is function.
Jun 19 '08 #6
n8kindt
221 100+
i just downloaded your file. if you are referring to the Create Expedite Reports > Email Report it seemed to work fine for me? i stopped the operation midway thru and checked the number of records (since the email_process form was open to view) for each of your combo boxes. 7844 had 4 records--it looped thru the code 4 times. 7848 had 14 records--it looped thru 14 times. 7863 also had 14 records--it looped thru 14 times as well. all loops also ran the sendobject method as well. is this the part u were referring to? u said it was randomly skipping the sendobject method right?

i can also vouch for the email working too lol.
Jun 19 '08 #7
nspader
78
i just downloaded your file. if you are referring to the Create Expedite Reports > Email Report it seemed to work fine for me? i stopped the operation midway thru and checked the number of records (since the email_process form was open to view) for each of your combo boxes. 7844 had 4 records--it looped thru the code 4 times. 7848 had 14 records--it looped thru 14 times. 7863 also had 14 records--it looped thru 14 times as well. all loops also ran the sendobject method as well. is this the part u were referring to? u said it was randomly skipping the sendobject method right?

i can also vouch for the email working too lol.
Yes that is exactly the part I was refering to. If I can ask. What version of access and emailing program are you using. I wonder if that is part of it.

Thanks. I am using access 2000 and outlook 2000, with a dll reference of Outlook 9 object library.

Nick
Jun 19 '08 #8
n8kindt
221 100+
Yes that is exactly the part I was refering to. If I can ask. What version of access and emailing program are you using. I wonder if that is part of it.

Thanks. I am using access 2000 and outlook 2000, with a dll reference of Outlook 9 object library.

Nick
i have Access 2007 and Outlook 2007 with the Microsoft Outlook 12.0 Object Library. i will try it one more time tonight to make sure it worked right so you're not barking up the wrong tree.

however, if i were u, i might consider taking a different approach than using microsoft outlook to send emails. i have a similar program set up and i used .cbo code from this website: http://www.paulsadowski.com/WSH/cdo.htm. if you would like, i could send you the function i created using this. this works very slick for me b/c i use microsoft access runtime 2007 and can set it up as a free independent program without having to install Microsoft Office on every computer to send emails. the only downside i have found about this is that you really have no way to go back and look at the actual email you sent unless u bcc all the emails to yourself.
Jun 19 '08 #9
nspader
78
i have Access 2007 and Outlook 2007 with the Microsoft Outlook 12.0 Object Library. i will try it one more time tonight to make sure it worked right so you're not barking up the wrong tree.

however, if i were u, i might consider taking a different approach than using microsoft outlook to send emails. i have a similar program set up and i used .cbo code from this website: http://www.paulsadowski.com/WSH/cdo.htm. if you would like, i could send you the function i created using this. this works very slick for me b/c i use microsoft access runtime 2007 and can set it up as a free independent program without having to install Microsoft Office on every computer to send emails. the only downside i have found about this is that you really have no way to go back and look at the actual email you sent unless u bcc all the emails to yourself.
Thank you for your help. I ended up doing something similar but still using Outlook. In our company we all use Outlook so it is appropriate to use it. However I realized that Sendobject was the easy way out at first, and we all know about that. ERROR ERROR ERROR. I went back and rewrote the code to call the outlook object and send it that way, with the export of the report just prior to the email message and attachment. It is working perfectly. Clearly it had something to do with the Sendobject (why or what I have no idea). I really appreciate your time on the matter. I will be sending this Program out company wide and want it to be perfect(as can be) before sending it out.

Nick
Jun 23 '08 #10
n8kindt
221 100+
Thank you for your help. I ended up doing something similar but still using Outlook. In our company we all use Outlook so it is appropriate to use it. However I realized that Sendobject was the easy way out at first, and we all know about that. ERROR ERROR ERROR. I went back and rewrote the code to call the outlook object and send it that way, with the export of the report just prior to the email message and attachment. It is working perfectly. Clearly it had something to do with the Sendobject (why or what I have no idea). I really appreciate your time on the matter. I will be sending this Program out company wide and want it to be perfect(as can be) before sending it out.

Nick
Great news! glad i could help. good luck
Jun 23 '08 #11

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

Similar topics

3
by: fred14214 | last post by:
Dear Group: I have built and customized a form using the wizard to put command buttons that will move to the NEXT record or PREVIOUS record. This works, but it needs some refinement. ...
3
by: Anthony Kroes | last post by:
I have a subform on a form and they are not linked. On the main form is a text box where the user types in a number. When that number changes, I have some code to make the corresponding text...
3
by: GGerard | last post by:
Hello I am trying to refer in code to the RecordsetClone of a subform datasheet but I'm getting syntax errors. This is what I am writing: Set MyDB = DBEngine.Workspaces(0).Databases(0)...
10
by: Thelma Lubkin | last post by:
My form/subform combination that allows user to display 'ColorSet' records, move to other records via a selector, to add,delete, and edit them, and to manage the related 'Color' records from the...
3
by: G Gerard | last post by:
Hello Can I write an SQL statement in code using a RecordSetClone of an open form? something like: MySQL = "UPDATE Me!Child0.Form.RecordSetClone SET Me!Child0.Form.RecordSetClone.MyField =...
1
by: RLC603 | last post by:
I have a form with subform which details documents within a contract and data elements within the documents. The form contains info. about the contract and one or several documents associated...
10
by: d.francis | last post by:
I have converted an Access 97 database to Access 2003 The following code now fails and returns Run-time error '3420' Dim rst as DAO.recordset Set rst = Forms!frm1!frm2.Form.RecordsetClone I...
1
by: Simon | last post by:
Dear reader, How can I move the record pointer in a sub form. The sub form is a datasheet type. Both forms have the same reference key. How can I move the record pointer in the sub form...
1
by: Kev | last post by:
Hi, I am trying to total a column (Shift1) in a subform (continous forms) from the after update event of the (Shift1) column control within the subform. This column stores shift codes, I want to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
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...

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.