Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:14:14+00:00 2026-06-04T18:14:14+00:00

I have a suppliers’ report about 150 pages in access 2007. Each report has

  • 0

I have a suppliers’ report about 150 pages in access 2007. Each report has address, emails contact person, phone number, products and name of company per page. Once a month I have to send an email to the suppliers to confirm changes of contact person address, phone number and products.

I want to send that particular report to that particular email not the whole report.
I want this to be automated.

I have written code in VBA after research on the net and still not working. I am getting Too many parameters. Expected 1. Error.

Below is code for my form with a Send Report button.

Dim strSql As String
Dim strSubject As String
Dim strMsgBody As String
strSql = "SELECT DISTINCT Name, EMail FROM [Suppliers and Products]"

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSql)

'loop through the recordset

 Do While Not rst.EOF
    ' grab email string

    strEmail = rst.Fields("EMail")

    ' grab name
    strName = rst.Fields("Name")

    Call fnUserID(rst.Fields("EMail"))

    'send the pdf of the report to curent supplier
    On Error Resume Next

    strSubject = "September 2012 Supplier's Listing"
    strMsgBody = "2008 Procedure Review Attached"
    DoCmd.SendObject acSendReport, "Suppliers Confirmation forms", acFormatHTML, strEmail, , , strSubject, strMsgBody, False

    If Err.Number <> 0 Then
        MsgBox Err.Number & vbCrLf & Err.Description, vbOKOnly, "Delivery Failure to the following email address: " & strEmail
    End If

    On Error GoTo PROC_ERR

    ' move and loop
    rst.MoveNext
Loop

' clean up
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing

PROC_Exit:
Exit Sub

PROC_ERR:
MsgBox Err.Description
Resume PROC_Exit

I have a module with the following code

Option Compare Database

Public Function fnUserID(Optional Somevalue As Variant = Null, Optional reset As Boolean = False) As Variant
    Static EMail As Variant
    If reset Or IsEmpty(EMail) Then EMail = Null
    If Not IsNull(Somevalue) Then EMail = Somevalue

    fnUserID = EMail
End Function

Public Function SendReportByEmail(strReportName As String, strEmail As String)
    On Error GoTo PROC_ERR

    Dim strRecipient As String
    Dim strSubject As String
    Dim strMessageBody As String
    'set the email variables
    strRecipients = strEmail
    strSubject = Reports(strReportName).Caption
    strMessageBody = "May 2012 Suppliers' List "

    ' send report as HTML
    DoCmd.SendObjectac acSendReport, strReportName, acFormatHTML, strRecipients, , , strSubject,    strMessageBody, False
    SendReportByEmail = True

    PROC_Exit:
    Exit Function
    Proc Err:

    SendReportByEmail = False

    If Err.Number = 2501 Then
        Call MsgBox("The email was not sent for " & strEmail & ".", vbOKOnly + vbExclamation + vbDefaultButton1, "User Cancelled Operation")
        Else: MsgBox Err.Description
    End If
    Resume PROC_Exit

End Function

The query which is report is getting its data has the following SQL.

SELECT Names.Name, Names.Phys_Address, 
       Names.Telephones, Names.Fax, Names.EMail, 
       Names.Web, Names.Caption AS Expr1, [Products by Category].CatName, 
       [Products by Category].ProdName
FROM [Names] 
INNER JOIN [Products by Category] 
ON Names.SuppID=[Products by Category].SupID
WHERE ((Names.EMail = fnUserID()) or (fnUserID() Is Null));

Please help as I am stuck to where I am going wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:14:16+00:00Added an answer on June 4, 2026 at 6:14 pm

    Some notes.

    On Error GoTo PROC_ERR
    
    Dim qdf As QueryDef
    Dim strSQL As String
    Dim strSubject As String
    Dim strMsgBody As String
    
    strSQL = "SELECT DISTINCT [Name], EMail, SuppID FROM Names " _
           & "INNER JOIN [Products by Category] " _
           & "ON Names.SuppID=[Products by Category].SupID "
    
    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset(strSql)
    
    qrySQL = "SELECT Names.Name, Names.Phys_Address, " _
           & "Names.Telephones, Names.Fax, Names.EMail, " _
           & "Names.Web, Names.Caption AS Expr1, " _
           & "[Products by Category].CatName, " _
           & "[Products by Category].ProdName " _
           & "FROM [Names] " _
           & "INNER JOIN [Products by Category] " _
           & "ON Names.SuppID=[Products by Category].SupID "
    
    'loop through the recordset
    
     Do While Not rst.EOF
        ' grab email string
    
        strEmail = rst.Fields("EMail")
    
        ' grab name
        strName = rst.Fields("Name")
    
        ' You should check that the email is not null
        Call fnUserID(rst.Fields("EMail"))
    
        'send the pdf of the report to curent supplier
        'On Error Resume Next
    
        'The query that the report uses
        Set qdf = CurrentDB.QueryDefs("Suppliers and Products")
        qdf.SQL = qrySQL & " WHERE SuppID=" & rst!SuppID
    
        strSubject = "September 2012 Supplier's Listing"
        strMsgBody = "2008 Procedure Review Attached"
        DoCmd.SendObject acSendReport, "Suppliers Confirmation forms", _
            acFormatHTML, strEmail, , , strSubject, strMsgBody, False
    
        ' move and loop
        rst.MoveNext
    Loop
    
    ''Reset the query
    qdf.SQL = qrySQL
    
    rst.Close
    Set rst = Nothing
    dbs.Close
    Set dbs = Nothing
    
    PROC_Exit:
    Exit Sub
    
    PROC_ERR:
        If Err.Number <> 0 Then
            MsgBox Err.Number & vbCrLf & Err.Description, vbOKOnly, _
              "Delivery Failure to the following email address: " & strEmail
        End If
    MsgBox Err.Description
    Resume PROC_Exit
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables: Suppliers(Sno, Sname, Address) Parts(Pno, Pname, Colour) Catalogue(Sno, Pno, Price)
I have a stored procedure which selects various information about suppliers. One of these
I have about 60,000 product images from various suppliers. Some of the images are
I have 3 types of users: Admins Suppliers Employees Each user type will have
I have suppliers table with id int value for each supplier. I'm trying to
My site has two types of users; customers and suppliers. I have ended up
I have a table of suppliers, and tables Computers, Cameras, Displays all containing the
I have a database of suppliers, they rent car. Most people rent for a
We have a supplier who provides a library for access to their hardware. Unfortunately,
Have a scenario with a client's new crm where they have suppliers and clients

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.