Error when using DoCmd.SendObject ac

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CRAZImat
    New Member
    • Aug 2023
    • 1

    Error when using DoCmd.SendObject ac

    Received the following error when clicking the command button to send the form in XLS format to recipients:

    "The expression On Click you entered as the event property setting produced the following error: User-defined type not defined.

    * The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure].
    * There may have been an error evaluating the function, event, or macro"

    Here is the Code that I used:
    Code:
    Private Sub Command_Click()	.
          DoCmd.SendObject acSendForm, "myForm", acFormatXLS, "someone@somewhere.com", , , _
    					"Email with attached report", "This is the email body.", True
    End Sub
    Looking for assistance in figuring out what I need to change in order to get this to work. I am using Access 2007-2016 (not my choosing). Thank you!
    Last edited by NeoPa; Aug 17 '23, 03:43 PM. Reason: Added [CODE] tags.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Hi CRAZImat.

    Welcome to Bytes.com.

    It looks like you've missed out a comma (,) from your invocation of the method (SendObject). You appear to have set the [Bcc] parameter to what looks like it might be your [Subject], and thus set [EditMessage] to True. It probably won't like that ;-)

    I should add that using positional parameters for methods with a complex list of parameters is not generally advisable. Named parameters makes much better sense (in such cases) and leads to far fewer problems.
    Last edited by NeoPa; Aug 17 '23, 03:52 PM.

    Comment

    Working...