Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do Loop Problem

Status
Not open for further replies.

plutz

Technical User
Oct 4, 2003
21
US
I have a database that i am try to loop through a table (maillist)of email address to send out different reports based on the field [deptid]. can you help

Dim project
project = Deptid
Do Until maillist.EOF
If project = 1 Then
DoCmd.SendObject acSendReport, "rptcalendar1", acFormatSNP, RP_email, , , "test", , False
ElseIf project = 2 Then
DoCmd.SendObject acSendReport, "rptcalendar2", acFormatSNP, RP_email, , , "test", , False
End If
maillist.MoveNext
Loop
 
i get an error message that an object is required
 
i get an error message that an object is required. I am unable to set project equal to the value in the field deptid
 
Let me amend that ... I do see one problem. "Project" is being set outside the loop so it will always have the initial value of DeptID for every iteration of the loop. Maybe you want
Code:
   If maillist![DeptID] = 1 Then
       DoCmd.SendObject acSendReport, "rptcalendar1", ...
   ElseIf maillist![DeptID] = 2 Then
       DoCmd.SendObject cSendReport , "rptcalendar2", ...
   End If
 
I still get the error message object required on the DO Until Maillist.EOF line
 
That message means that it is expecting a recordset object and "maillist" isn't one. How and where is "MailList" Dim'ed?
 
a macro opens maillist form prior to running the code
 
Forms do not have an "EOF" property. Recordsets have an EOF property. You can (probably) use the RecordsetClone of the form, but you obviously need to spend some time in the ubiquitous {F1} arena (aka help) or other tutorial(s) to understand the basic operation of Ms. A.





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top