Re: Looping through Records question
- From: "Douglas J. Steele" <NOSPAM_djsteele@xxxxxxxxxxxxxxxxx>
- Date: Mon, 29 Jan 2007 18:51:28 -0500
Sort of academic, since Kimberley reported it now "worked perfectly".
I believe that "RptName cannot contain a string" was a slightly misword
response to my question "Do you mean that RptName can contain a string like
'Report1,Report2,Report3'?" intended to mean that it wouldn't contain a
concatenated string.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"Argusy" <argusy@xxxxxxxxxxxxxxx> wrote in message
news:45BD6CF2.9060400@xxxxxxxxxxxxxxxxxx
Your answer is confusing!!
the word 'report1' IS a string of eight characters, yet you state RptName
cannot contain a string. (You've even defined it as a container for
strings)
Are you referring to the database 'ReportName' (is it string or numeric?)
Bugger, just had a callout - Douglas will continue with this
Argusy
Kimberley wrote:
I also had a couple of things named incorrectly. But removing the
DLOOKUP and using recordset worked perfectly.
Thanks again for your help
On Jan 24, 5:48 pm, "Kimberley" <ksmi...@xxxxxxxxx> wrote:
Thanks for your reply. In answer to your question, RptName cannot
contain a string.
It contains only one report name. Each row in the table has the
following:
ID ReportName EmailtoName CCName
1 Report1 mbr...@xxxxxxxxxx jjohn...@xxxxxxxxxx
What I want to do is send the Report1 to the EmailtoName and the
CCName listed in the same row. And then move on to the next one.
I followed your advice but I am still getting the same report (Report1)
over and over.
On Jan 24, 4:56 pm, "Douglas J. Steele"
<NOSPAM_djsteele@xxxxxxxxxxxxxxxxx> wrote:
Do you mean that RptName can contain a string like
"Report1,Report2,Report3"? If so, you really should read up on database
normalization: storing multiple values in a single field is a bad idea.
If RptName is a single report name, then you need to take advantage of
the
fact that you've opened a recordset. Using DLookup is going to return
the
same value every time.
The 3 lines
Emailto = DLookup("EmailtoName", "tbl_ReportList")
CC = DLookup("CCName", "tbl_ReportList")
RptName = DLookup("ReportName", "tbl_ReportList")
should be
Emailto = rst!EmailtoName
CC = rst!CCName
RptName = rst!ReportName
--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)
"Kimberley" <ksmi...@xxxxxxxxx> wrote in
messagenews:1169658283.200316.142520@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi all,
I have a table in access (tbl_ReportList) that has four fields (ID,
Emailto, CC, and RptName). The email and CC fields both have e-mail
addresses in them and the RptName field is a list of reports in the
database. For now I only have three: Report1,Report2,Report3.
When I run the code below, the same report "Report1" keeps getting
sent. Can someone please tell me what I'm doing wrong in the loop. For
now, I only have three reports but by the end it will be about 150.
Thanks in advance for any help,
Private Sub Command0_Click()
Dim db As database
Dim rst As DAO.Recordset
Dim x As Integer
Dim Emailto As String
Dim CC As String
Dim RptName As String
Set db = CurrentDb()
Set rst = db.OpenRecordset("tbl_ReportList", dbOpenDynaset)
With rst
If Not (.EOF And .BOF) Then
rst.MoveFirst
Do Until rst.EOF
For x = 1 To 140
Emailto = DLookup("EmailtoName", "tbl_ReportList")
CC = DLookup("CCName", "tbl_ReportList")
RptName = DLookup("ReportName", "tbl_ReportList")
DoCmd.SendObject acReport, RptName, "SnapshotFormat(*.snp)", _
Emailto, CCto, "", "Attention Required Report", "", False,
""
rst.MoveNext
Next
Loop
End If
End With
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub- Hide quoted text -- Show quoted text -- Hide quoted text --
Show quoted text -
.
- Follow-Ups:
- Re: Looping through Records question
- From: Argusy
- Re: Looping through Records question
- References:
- Looping through Records question
- From: Kimberley
- Re: Looping through Records question
- From: Douglas J. Steele
- Re: Looping through Records question
- From: Kimberley
- Re: Looping through Records question
- From: Kimberley
- Re: Looping through Records question
- From: Argusy
- Looping through Records question
- Prev by Date: Re: Looping through Records question
- Next by Date: Re: Looping through Records question
- Previous by thread: Re: Looping through Records question
- Next by thread: Re: Looping through Records question
- Index(es):
Relevant Pages
|
Loading