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.
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.
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
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.
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.
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.
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!!![]()
No problem. I'm surprised that works, but I'm glad it does.
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.