parentheses in field text stop email from sending (1 Viewer)

BarryMK

4 strings are enough
Local time
Today, 15:13
Joined
Oct 15, 2002
Messages
1,350
I’m using the following code behind a command button to send an email with field contents from a form and generally it works fine.

Code
Application.FollowHyperlink "mailto:joe.soap@somewhere.gov.uk;&subject=About improvement logged on QMS1 &body=Record number: " & Me!txtIncidentID & " Raised by " & Me!cmbIdent & " Details are: " & Me!memProbDesc & " Actions listed: " & Me!ActionDesc, , True
End Code

When a user raises an improvement for our ISO system, he free types text into the description field memProbDesc. However If the he types parentheses as part of the text, the email won’t send and I get an Outlook error dialog saying - The command line argument is not valid. Verify the switch you are using.

I don’t want to prevent the users from typing any necessary text characters if possible. Any ideas
 
I've put the following workaround in but would prefer not to do it this way.
Code:
Private Sub memProbDesc_BeforeUpdate(Cancel As Integer)
       If Me.memProbDesc Like "*""*" Then
MsgBox "If you use "" signs in this field the email will not send", vbInformation, "Don't use quotation marks"
End If
End Sub
 
Workaround No 2

I set AutoCorrect to change " to ' and set AutoCorrect to yes on the field.
 
You are correct in that it's not parentheses, but rather the quotes " in the memo field. Instead of using AutoCorrect (which can be disabled), do a Replace on the Memo Field after the entry is done but before the email is sent. The code will look like this:

YourMemoFieldName = Replace(YourMemoFieldName, """", "'")

If you come across any other weird characters, you can use the same replace method for each one, replacing the "offending" character with a not-so-offensive one.

I added color so you could make out everything in there.
 
Last edited:
Perfect.

I learn something new every time I visit. I've never needed (or knew anything about) the replace function before but it's going into my code library Thanks very much
 

Users who are viewing this thread

Back
Top Bottom