Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Quote Originally Posted by ssanfu View Post
    For clarification:
    These 2 buttons are on the REPORT rptSelectChanges, not a form????
    "Email" on rptSelectChanges - on the Report

    "Send" is on the actual email message as designed on MS Outlook. I didn't make that one.




    I have two buttons on the form frmSelectChanges

    "Cancel" and "Select" the "Select" button drives the MyChanges VBA

  2. #17
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK, that helped clear things up (I hope).

    (I have never use buttons on a report. )


    Try this (on a copy of the dB for safety sake):
    1) On "frmSelectChanges" create an unbound text box. Name it "tbWHERE". At some point it could/should be hidden.

    2) In the routine "SelectChanges_Click", add the line(in blue)
    Code:
    Public Sub SelectChanges_Click()     
    Dim strWhere As String, ctl As Control, varItem As Variant
        Set ctl = Me.MyChanges
       
    If Me.MyChanges.ItemsSelected.Count = 0 Then
         MsgBox "Nothing was selected"
            Exit Sub
        End If
    
    For Each varItem In ctl.ItemsSelected
       strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
    
    Next varItem
       strWhere = Left(strWhere, Len(strWhere) - 1)
       Me.tbWHERE = strWhere
       DoCmd.OpenReport "rptSelectChanges", acViewReport, , "CRNumber IN(" & strWhere & ")"
       DoCmd.Close acForm, "frmSelectChanges"
    End Sub

    3) Change "SendSelectCRs_Click" to this:
    Code:
    Public Sub SendSelectCRs_Click()
    
        Set objOutlook = CreateObject("Outlook.Application")
        Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    
    
        With objOutlookMsg
             .Subject = NIE & " Selected Changes(s) - " & Forms!frmSelectChanges.tbWHERE & " - " & Tod
            .Body = SigBlock
            DoCmd.OutputTo 3, "rptSelectChanges", acFormatPDF, "C:\Temp\" & NIE & " Selected Changes - " & Tod & ".pdf", , 0
            .Attachments.Add ("C:\Temp\" & NIE & " Selected Changes - " & Tod & ".pdf")
            .Display
            Kill "C:\Temp\" & NIE & " Selected Changes - " & Tod & ".pdf"
        End With
    
        DoCmd.Close acReport, "rptSelectChanges"
        DoCmd.OpenForm "frmStart"
    
        Set objOutlookMsg = Nothing
        Set objOutlook = Nothing
        Set objOutlookAttach = Nothing
    
    End Sub

  3. #18
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Much thanks for your assistance Steve.
    I got it to work with what you provided. I did make a small change from Form! to Form_frmSelectChanges.tbWhere

    I did add this in also:

    Dim strCRs As String
    strCRs = Form_frmSelectChanges.tbWhere
    strCRs = Replace(strCRs, "'", "")
    strCRs = Replace(strCRs, ",", ", ")

    I took it from '2.00','3.01',.....

    to 2.00,3.01,.....

    to 2.00, 3.01, 4.77....

    Numbers are an possible example.

    I didn't see an easier way except the replace.

    Thanks again

  4. #19
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You might try changing the code in "Sub SelectChanges_Click() "

    1) adding the space after the comma:
    Code:
    For Each varItem In ctl.ItemsSelected
       strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"  '<<-- add a space after the comma. (won't need one Replace statement)
    
    Next varItem
    2) Also try removing the single quotes and see if the report has the same data.
    The line would look like
    Code:
    For Each varItem In ctl.ItemsSelected
       strWhere = strWhere & ctl.ItemData(varItem) & ", "   'no single quotes and added space after comma
    Next varItem

    Glad you got it working the way you want....

  5. #20
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Steve,
    I went this route:
    in frmSelectChanges I added

    strWhere2 = strWhere2 & " " & ctl.ItemData(varItem) & ", "

    Me.tbWhere = strWhere2

    and then referenced it in the email subject line and the report output line.

    Thanks again very much.

  6. #21
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Happy to help...

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

Similar Threads

  1. Missing stuff in Email Subject line
    By Thompyt in forum Programming
    Replies: 3
    Last Post: 04-13-2016, 02:26 PM
  2. Replies: 5
    Last Post: 11-01-2014, 05:18 PM
  3. Multiple Data on one line?
    By alicias4 in forum Reports
    Replies: 2
    Last Post: 02-07-2013, 05:53 PM
  4. VBA check for email subject line
    By problem_addic in forum Access
    Replies: 4
    Last Post: 03-12-2010, 02:33 PM
  5. Multiple detail items per line
    By needafix in forum Reports
    Replies: 3
    Last Post: 10-22-2009, 11:04 AM

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