Page 3 of 3 FirstFirst 123
Results 31 to 36 of 36
  1. #31
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742

    probably formatpdf needs to be acFormatPDF.

  2. #32
    Gina Maylone is offline Always learning
    Windows 7 64bit Access 2013
    Join Date
    Jun 2013
    Location
    Afton, MN
    Posts
    544
    Sorry it's taken so long to get back to this. I am still getting the error Too Few parameters, expected 2. I will highlight the line that it happens.
    Code:
     (sorry I still don't have a code icon)
    Dim rsEmail As DAO.Recordset
    
    Dim strEmail As String
    Dim strSubject As String
    Dim strContactName As String
    
    Set db = CurrentDb
    Set qDef = db.QueryDefs("EmployeeEmailQuery")
    
    Set rsEmail = qDef.OpenRecordset
    
    Do While Not rsEmail.EOF
    strEmail = rsEmail.Fields("emailaddress").Value
    
    'strContactName = rsEmail.Fields("fullName").Value
    
    DoCmd.SendObject acSendReport, "schedule", acFormatPDF, strEmail, , "" & Me!Subject, "" & Me!Greeting, "" & Me!Message
    'DDoCmd.SendObject acSendReport, "schedule", formatpdf, strEmail, , , """" & Me!Subject & """", """" & Me!Greeting & """", """" & Me!Message & """"oCmd.SendObject acSendReport, "schedule", formatpdf, strEmail, , , """" & Me!Subject & """", """" & Me!Greeting & """", """" & Me!Message & """"
    ' False
    
    rsEmail.MoveNext
    
    Loop
    
    Set rsEmail = Nothing
    Set qDef = Nothing
    Set db = Nothing
    
    MsgBox "Emails have been sent"

  3. #33
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I have just a couple of questions. What are the criteria in your query EmployeeEmailQuery I'm assuming it has 2 criteria that are based on a reference to a form?

    If so you *may* be able to solve the parameter prompt by putting parameters in your query

    so let's say in your query you have the criteria [Forms]![frmTest]![SearchField1], create a parameter in your query with the exact same syntax and define the data type that you expect for that field/parameter.
    If EmployeeEmailQuery is a crosstab you may have some other difficulties with it.


    Secondly

    DoCmd.SendObject acSendReport, "schedule", acFormatPDF, strEmail, , "" & Me!Subject, "" & Me!Greeting, "" & Me!Message

    You don't need the "" marks in your subject and greeting you should be able to do this:

    DoCmd.SendObject acSendReport, "schedule", acFormatPDF, strEmail, , Me!Subject, Me!Greeting, Me!Message

    what was the purpose of putting in the "" & in each one of these?

  4. #34
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    rpeare - using "" & fieldname handles nulls automatically without any logic.

    Gina - after all the code put /code in square brackets.

    try this:
    Code:
    DoCmd.SendObject acSendReport, "schedule", acformatPDF, strEmail, , , "" & Me!Subject, "" & Me!Greeting, "" & Me!Message
    And get rid of all the comments and duplicates in that area of the code. You don't need to keep copies of things that didn't work.

  5. #35
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Yes Dal but why would you want those values to be null, you'd just be inserting an empty string, that's what I'm getting at, what would be the purpose of creating, essentially, a blank email if those values were null. Wouldn't it be better to prevent the email from being generated at all if any of those items were missing and notify the user so they could fix whatever's missing. Regardless of how you handle nulls the parameter issue is the part that needs fixing and I'm wondering if it's a crosstab or just a regular select query.

  6. #36
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    I see. Yes, it would seem like, once she gets the minimum functionality
    she needs, that some additional error trapping would be a good idea for
    the subject and message text boxes.

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error 3061 - Too Few parameters
    By DetrieZ in forum Programming
    Replies: 2
    Last Post: 07-09-2013, 12:52 PM
  2. Replies: 3
    Last Post: 04-26-2013, 01:37 PM
  3. Runtime Error 3061 Expected 3
    By kumail123 in forum Programming
    Replies: 1
    Last Post: 03-28-2012, 09:44 AM
  4. 3061 Error. Too few parameters. Expected 1.
    By rghollenbeck in forum Queries
    Replies: 5
    Last Post: 09-28-2011, 12:12 PM
  5. Replies: 1
    Last Post: 05-21-2011, 01:33 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums