Run-time Error 3061

M

Mike C

Hi. I have some code that emails reports to people by looping through record
sets. The first is a table named "Report" which lists some company reports
and has two fields, ReportID and ReportDesc. The second, a query named
"vwReportDistribution", lists who should receive each report and pulls in
their information such as email address etc. The query is comprised of
several tables; one is a table called ReportDistribution which has two
columns (EmployeeID, ReportID) that determines who gets which reports. The
columns are combo boxes with bound columns that store the ID number but
display the name of the person and the name of the report. For some reason,
however, the code below keeps telling me "Run-time Error 3061, Too Few
Parameters, Expected 1." I know this is pretty common and probably an easy
fix but I'm stuck :(

The code is below. When I change the last line from "WHERE
[ReportID]=rsReport![ReportID]" to "WHERE [ReportID]=5", for example, it
allows my code to run. So, I think it's just having trouble reading
rsReport![ReportID] and I need to come up with some way to define that
parameter or something. Any suggestions would be tremendously helpful. Thanks!

Set db = CurrentDb

Set rsReport = db.OpenRecordset("SELECT * " & _
"FROM [Report]" & _
"WHERE [Send] = -1")

If Not rsReport.EOF Then
Do While Not rsReport.EOF

Set rsDistributionList = db.OpenRecordset("SELECT * " & _
"FROM [vwReportDistribution]" & _
"WHERE [ReportID]=rsReport![ReportID] AND [SMSTIME]=#6:00:00 AM# AND
Not [MobilePhone] Is Null and Not [MobileProviderID] Is Null")
 
J

jpr

Try delimiting the ReportID like this:
"WHERE [ReportID] = " & rsReport![ReportID] & " AND [SMSTIME] ....."
This allows the SQL statement to see the value of reportID instead of the
reference to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top