Re: win2pdf mail helper loop
- From: "Stephen Lebans" <ForEmailGotoMy.WebSite.-WWWdotlebansdot...@xxxxxxxxxxxx>
- Date: Fri, 20 Jun 2008 00:38:07 -0300
Try placing your code in the form's Load event instead of the Open event.
Before invoking your looping construct you should Move to the first row of
the recordset.
Your looping construct does not test for EOF before processing the loop.
Here's some example code for itinerating through a recordset attached to a
from.
With Me.RecordsetClone
' Move to first record
.MoveFirst
' Loop until all records are processed
' This example uses a field named "Comment"
' Note this is the name of the FIELD not the
' name of the TextBox control bound to this field
Do While Not .EOF
.Edit
sText = IIf(IsNull(.Fields("Comment")), "", .Fields("Comment"))
' See if field is empty
If Len(sText & vbNullString) = 0 Then
sRTFdata = sHeader & "}"
Else
sRTFdata = sHeader & sText & "\par }"
End If
' Save our RTF encoded string back to Comment field
.Fields("Comment") = sRTFdata
.Update
' Move to next record
.MoveNext
Loop
End With
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Maverick6197" <u42957@uwe> wrote in message news:85ebf92b5cc79@xxxxxx
I've posted this before, but haven't been able to get an answer.....
Here's what I'm trying to do.....
I have a form who's recordsource is a query that pulls records with a date
of
30 days before today's date.
In the OnOpen() Event of the form, I have placed code that uses the
information from the form to build a report. The report is then e-mailed
to
the e-mail address on the form using the win2pdf Mail Helper program. The
code then tells the form to go to the next record and repeat everything
for
this record as well.
The problem is that the first report is e-mailed to the e-mail address
twice
and I cannot figure out why. The report for the second record is only
sent
once.
Here is my code........
---------Start of Code-------------------
Option Explicit
Private Const REG_DWORD As Long = 4
Private Const HKEY_CURRENT_USER = &H80000001
Private Const KEY_ALL_ACCESS = &H3F
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As
Long)
As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias
"RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal
ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegSetValueExLong Lib "advapi32.dll" Alias
"RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal
Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As
Long)
As Long
Private Sub SaveWin2PDFDword(sValueName As String, lValueSetting As Long)
Dim lRetVal As Long 'result of the SetValueExLong function
Dim hKey As Long 'handle of open key
lRetVal = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\VB and VBA Program
Settings\Dane Prairie Systems\Win2PDF", 0, KEY_ALL_ACCESS, hKey)
lRetVal = RegSetValueExLong(hKey, sValueName, 0&, REG_DWORD,
lValueSetting,
4)
RegCloseKey (hKey)
End Sub
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_cmdLoadReport_Click
Loop_cmdLoopReport_Click:
Dim ProtecCode As String
ProtecCode = Me.txtEmailContact
SaveWin2PDFDword "file options", &H421
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFMailFrom", "No-
Reply@xxxxxxxxxxxxxxxxxxxx"
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFMailRecipients",
ProtecCode
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFMailSubject",
"PROTEC -
NOTIFICATION OF WARRANTY STATUS"
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFMailNote", "Please
see
the attached document concerning a unit registered with Astec Underground
by
your dealership. DO NOT REPLY TO THIS E-MAIL."
SaveSetting "Dane Prairie Systems", "Win2PDF", "PDFFileName", "T:\
Customer Support\Protec\Protec Warranty Status Notifications\" & Me.
txtDealerNumber & " - " & Me.txtUnitSerialNumber & ".pdf"
DoCmd.OpenReport "rptProtec", acViewNormal
DoEvents
'Forms![frmProtec].SetFocus
DoCmd.GoToRecord , , acNext
DoEvents
'Forms![frmProtec].SetFocus
GoTo Loop_cmdLoopReport_Click
Exit_cmdLoadReport_Click:
Exit Sub
Err_cmdLoadReport_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdLoadReport_Click
End Sub
---------End Code----------
Any help would be greatly appreciated. Thanks in advance.....
Shannan
--
Message posted via http://www.accessmonster.com
.
- Follow-Ups:
- Re: win2pdf mail helper loop
- From: Maverick6197 via AccessMonster.com
- Re: win2pdf mail helper loop
- References:
- win2pdf mail helper loop
- From: Maverick6197
- win2pdf mail helper loop
- Prev by Date: Re: Navigation panel with buttons
- Next by Date: Re: Re-size an image to fit
- Previous by thread: win2pdf mail helper loop
- Next by thread: Re: win2pdf mail helper loop
- Index(es):