Results 1 to 7 of 7
  1. #1
    dshillington is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    7

    Help with ElseIf Statements

    I have programmed a VBA to email a form to a specific email group, and included a CC based on a check box. I am trying to add additional emails to that CC box based on other check boxes in my form. Stumped on how to do this.



    Set objOutlook = CreateObject("Outlook.application")
    Set objEmail = objOutlook.CreateItem(olMailItem)
    With objEmail
    .SentOnBehalfOfName = "Mailbox sent from"
    .Importance = olImportanceHigh
    .To = "@Outlook Email Group"
    If Me.Check96 = True Then
    .CC = "multiple email addresses"
    ElseIf Me.MAA = True Then
    .CC = Me.Check96 And "optional email addresses to be added to the CC group based on another check box"
    End If

    What am I doing wrong????

    Dave

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If I'm following what you want to do:

    .CC = .CC & "optional email addresses to be added to the CC group based on another check box"
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    By the way, you realize the ElseIf will only run if Check96 is False?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    dshillington is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    7
    That's exactly what I want. What would the code look like inserted into mine? Mucho gracias!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Not clear what you're asking; it would look exactly like that (you would presumably have addresses in the string). & is a concatenation operator, so will join the previous string with the new string.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    dshillington is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2011
    Posts
    7
    Sorry, still pretty new to this. I guess I,m wondering if I use an ElseIf statement for this?

    Your help is greatly appreciated.

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Depends on the logic you want applied. If each checkbox will optionally add to the string, then no.

    Code:
    If (Me.Checkbox1) Then
      .CC = .CC & ...
    End If
    
    If (Me.Checkbox2) Then
      .CC = .CC & ...
    End If
    By the way,
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Easy one, If then ElseIf
    By Bruce in forum Forms
    Replies: 4
    Last Post: 12-01-2011, 12:44 PM
  2. IIF() statements
    By ajetrumpet in forum Tutorials
    Replies: 0
    Last Post: 06-17-2011, 06:51 PM
  3. If statements
    By swagger18 in forum Programming
    Replies: 6
    Last Post: 01-28-2011, 08:13 PM
  4. IIF statements?
    By staceyo in forum Queries
    Replies: 15
    Last Post: 09-28-2010, 08:45 AM
  5. If statements
    By Ezeecopy in forum Access
    Replies: 0
    Last Post: 03-24-2009, 04:54 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