Results 1 to 11 of 11
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Form double click field to email what is in the field

    I am using docmd.SendObject(,,,me.txt1ContactEmail,,,The & " " & Company & " " & Name,,,,)

    but I keep getting a syntax error - what and I missing??

    It's to email what is in the field on a double click event.

  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,640
    For starters, there shouldn't be any parentheses. Secondly, you've got what appears to be fixed text outside quotes. Perhaps

    "The " & Company & " Name"

    Edit: also no trailing commas
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Thanks - I used this and it works fine

    DoCmd.SendObject , , , Me.txt1ContactEmail, , , "The" & " " & "Company" & " " & "Name"

    I get an error if I cancel the email (which I would like to learn how to create an error handler for that)

    I'm probably going to add an "if" isnull do nothing and if not isnull docmd so that it only emails if there is an email in the field (unless of course they don't type an email in the field correctly and forget the @ symbol and then I'm going to have more problems. They being the user.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    No problem. Here's a primer on error handling:

    http://www.baldyweb.com/ErrorTrap.htm

    The error for not sending I think is 2501, but test that. If that's your actual code, there's no need for all the concatenation.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I tried

    DoCmd.SendObject , , , Me.txt1ContactEmail, , , "The" & " " & "Company" & " " & "Name"
    On Error GoTo ErrorHandler


    ErrorHandler:
    Select Case Err
    Case 2501
    DoCmd.RefreshRecord
    End Select


    without much success - I don't need a message or anything - would prefer nothing to happen.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    The order of things in that link is important. You can eliminate the message box from the specific error number.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    The order of things in that link is important. You can eliminate the message box from the specific error number.


    You can ask 2501 to not display at all?

    I still don't know how to make the field have the force correct format before emailing (if they forget the @ symbol I am going to get an error) either.

    I retyped it as this
    On Error GoTo ErrorHandler
    DoCmd.SendObject , , , Me.txt1ContactEmail, , , "The" & " " & "Company" & " " & "Name"



    ErrorHandler:
    Select Case Err
    mesbox "You cancelled the email"
    DoCmd.RefreshRecord
    End Select

    and that works but I still don't know about the field if it has the wrong information entered.

    Never mind I tried out some trial runs and it works out fine - thank you very much for your help pbaldy!!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    No problem. I'm surprised that works, but I'm glad it does.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    No problem. I'm surprised that works, but I'm glad it does.
    well null means it won't run command in the first place so that sorts out that problem, then I made the error close the form after displaying a reason as a messagebox.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Unless there's more to the code than posted in #7, you will always get the message box, whether they cancel the email or not.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by pbaldy View Post
    Unless there's more to the code than posted in #7, you will always get the message box, whether they cancel the email or not.
    It's only on the occurrence of an error.

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

Similar Threads

  1. Replies: 6
    Last Post: 04-26-2013, 10:07 AM
  2. On Double Click Open Form with two criteria
    By AndreasPanayiotou in forum Programming
    Replies: 3
    Last Post: 09-10-2012, 08:47 AM
  3. Replies: 1
    Last Post: 03-15-2012, 05:41 PM
  4. Replies: 7
    Last Post: 01-12-2011, 08:59 AM
  5. Opening another form by double click
    By chrisjack001 in forum Access
    Replies: 1
    Last Post: 10-13-2010, 02:19 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