Results 1 to 3 of 3
  1. #1
    mchadwick is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Sep 2011
    Posts
    71

    VBA code for macro

    Hi, I'm simply trying to add some macro code (convert macro to Visual Basic is greyed out).

    I have an email VBA to create an email and I would like to add the ability to go to a field (checkbox) and set it to yes. I have the Macro set with this:

    SetValue
    Item =[Sent]
    Expression =Yes

    Here is the code I've created for the email

    Private Sub Command24_Click()


    Dim Msg As String

    Msg = "Hello " & [Pref_First] & ",<br>" & _
    " text text text.<P>"




    Dim O As Outlook.Application
    Dim M As Outlook.MailItem


    Set O = New Outlook.Application
    Set M = O.CreateItem(olMailItem)


    With M
    .BodyFormat = olFormatHTML
    .HTMLBody = "<IMG src= C:\Users\mc900136\Documents\header.jpg width=450><br>" & Msg
    .To = [Email - Primary Work]
    .CC = [Manager Email]
    .Subject = "Domain\Tenant Consolidation - Questionnaire Duel Account User"
    .Display



    End With


    Set M = Nothing
    Set O = Nothing




    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Please post code between CODE tags to retain indentation and readability. You can edit your post.

    Don't have to 'go to' a control/field to set its value. If field is in this form's RecordSource and focus is on record to edit, simply: Me.checkboxname = True.
    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.

  3. #3
    mchadwick is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Sep 2011
    Posts
    71
    yeah, I'm sorry I forgot to do that. Thanks for the response though. worked perfectly

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

Similar Threads

  1. NPV Macro Code in VBA
    By aisa.imn98 in forum Modules
    Replies: 5
    Last Post: 04-23-2021, 11:18 AM
  2. Can I run a VBA code from a macro?
    By geotrouvetout67 in forum Programming
    Replies: 4
    Last Post: 08-22-2019, 02:59 PM
  3. Macro Code Help
    By Chris12 in forum Access
    Replies: 4
    Last Post: 05-28-2019, 11:09 AM
  4. Help with NPV Macro Code in VBA
    By BigNasty in forum Macros
    Replies: 6
    Last Post: 11-21-2016, 10:39 PM
  5. VBA code/Macro help please.
    By Davidyam in forum Access
    Replies: 1
    Last Post: 02-26-2012, 09:59 PM

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