Page 2 of 5 FirstFirst 12345 LastLast
Results 16 to 30 of 66
  1. #16
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Believe me, we are doing our best to try and understand your issue. I ask questions when I don't and I think we do understand what you want but conveying instructions not always easy in print.



    I disagree about referencing code produced under older versions. VBA hasn't changed much and ideas can be derived from examples.

    I don't see Order_ID on the form image except referenced in textbox expression.

    Missing = sign; try ! instead of . referencing Order_ID (really, either should work):

    DoCmd.OpenReport "Invoice", acViewNormal, , "Order_ID=" & Me!Order_ID

    If that fails, use [] because the field names really have spaces, not underscore:

    DoCmd.OpenReport "Invoice", acViewNormal, , "[Order ID]=" & Me![Order ID]

    That code assumes Order_ID is number, not text field.

    Use a real email address in place of "email address" or maybe a reference to control name on form (just guessing about name): Me.Email

    It might be necessary to commit the record entry/edit to table before it is available for the report output.

    DoCmd.RunCommand acCmdSaveRecord

    Learn debug methods. Refer to link at bottom of my post for VBA debugging techniques.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  2. #17
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    Thank you again June...but its still not working...

    The Field has spaces so I used the following:

    DoCmd.OpenReport "Invoice", acViewNormal, , "[Order ID]=" & Me![Order ID]

    Kept getting debug error...so I went to the Invoice Table that this is taken from and went into Design View..I did see Invoice ID in design view but not in Data View (first off what is that?) And yes they are both a number...

    So then I tried the following:

    Private Sub Report_Open(Cancel As Integer)
    DoCmd.OpenReport "Invoice", acViewNormal, , "[Invoice ID]=" & Me![Order ID]
    DoCmd.SendObject acSendReport, , acFormatPDF, "email address", , , "Invoice", "email body text"
    End Sub

    no more debugging...but still cant get the PDF to attach to email. Now before I was told to do it on OnOpen in events. Should I try doing it when we Double Click on Email?

  3. #18
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Why would you have code to open report in that report's open event? That's just not logical. All programming is an exercise in logic. Yes, the code I offer would go in event behind form. Could be a button Click or box AfterUpdate or DoubleClick. Whichever is most convenient and appropriate for the user because don't want report to run before all data is committed to table. I edited previous post regarding the commitment issue, in case you missed it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #19
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    Ok now we are getting somewhere somewhat...

    I changed it to OnDblClick ..I am able to view the ONE invoice. But when I go to email and double click on it then it attaches all invoices that not only belongs to this customer it also attaches every invoice of other customers too in PDF.

    How can I get it to ONLY attach the ONE invoice in email?

  5. #20
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    DoCmd.RunCommand acCmdSaveRecord where do i put this at? under what event?

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Save record in same event code, just before OpenReport

    What do you mean by "go to email and double click on it" - double click on email?

    The code should open report then open Outlook with the report attached as a PDF and the PDF should have only one invoice. Works for me.

    I give up. Provide db for analysis.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #22
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You don't specify the report in the SendObject line, which I would do. Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #23
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    If report is not specified, code will use the opened report. Works for me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #24
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    Database5.zip

    Ok now when you open go to LOGIN go to Charles Fulbright name

    Click on New Customer Order

    Select Tate Supply as customer

    Select any product that has any quanity in it to sell

    You will get a popup Expression Error and just exit out of that debugging (dont worry I know what that issue is..but I am waiting on some people here to get me the correct information for that before I go on and fix that issue)

    Then go to shipping and select any shipper (which I have to figure out how to change this option as it wont let you create invoice without it and there are times when we have to send this to customer without the shipper info at that time)

    Click on Create Invoice and you will see only the ONE invoice shows up

    Then double click on the email address and watch it go crazy :-)

    Let me know please on what you can do for me :-)

    And thank you BOTH!! :-)

  10. #25
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I guess somebody bailed? You've got an embedded macro there, not the suggested VBA code. This works:

    DoCmd.OpenReport "Invoice", acViewPreview, , "[Order ID]=" & Me![Order ID]
    DoCmd.SendObject acSendReport, , acFormatPDF, , , , "Invoice", "email body text", True
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #26
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Bailed, not quite, just gave up trying to analyse from post narrative. I have limited use of Access 2010 until I fix or replace my computer. The file wouldn't open for me under 2007.

    Be sure to select [Event Procedure] in the event property if you want to use VBA. Then click the ellipses (...) to go to procedure in VBA editor. I looked for the VBA code I suggested but it isn't there.

    I followed your instructions but when I click Create Invoice get message "Cannot create invoice! Inventory has not been allocated for each specified product."
    Last edited by June7; 04-24-2013 at 09:11 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #27
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    June, its because you selected a product that either didnt have any in stock or you didnt select quantity. I am trying everything you all said and I will let you know if it works :-)

  13. #28
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    Paul,

    where did you see the embedded macro? Also, do I put the code you posted under the properties of Invoice or Order Details?

  14. #29
    Stephanie53 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    246
    June,

    It was under Order Details in the Properties of that form. Did I put it in wrong place?

  15. #30
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by Stephanie53 View Post
    Paul,

    where did you see the embedded macro? Also, do I put the code you posted under the properties of Invoice or Order Details?
    I believe it was in the double click event of the email address. Code goes here:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 2 of 5 FirstFirst 12345 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sending HTML files via Access to Outlook
    By Yann63 in forum Programming
    Replies: 4
    Last Post: 02-13-2014, 05:34 PM
  2. sending data into an email body - outlook
    By webisti in forum Access
    Replies: 6
    Last Post: 02-15-2012, 07:05 AM
  3. Sending Outlook E-mail - Run-time error '429'
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 03-01-2011, 09:30 AM
  4. Replies: 1
    Last Post: 03-09-2006, 01:50 PM
  5. Sending email via Outlook (and Exchange2003) from Access2003
    By Larry Elfenbein in forum Programming
    Replies: 0
    Last Post: 11-15-2005, 09:03 PM

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