Solved

Array is passing values with double double quotes to another procedure

Posted on 2012-03-20
6
415 Views
Last Modified: 2012-03-20
I am working on taking a string of user ids in a text box, changing themto an array adn then passing each userid to a procedure.  However, I don't know why I keep getting double double quotes when it passes the aarry values.  What appears in the text box is in the fomat of   "ssmith", "jones", "brown"    This procedure is in VBA behind an Access 2003 form.

Sandra

'Create email and text to Administration with user's suggestion
On Error GoTo ErrorHandler
Dim EmailBody As String
Dim ToEmailAddress As String
Dim FromEmailAddress As String
Dim strSelect As String
Dim strCriteria As String
Dim strSplit() As String
Dim i As Integer

FromEmailAddress = "sgsmith@someplace.com"
ToEmailAddress = "sgsmith@someplace.com"
strCriteria = Me.txtCriteria

strSplit = Split(strCriteria, ", ")
For i = LBound(strSplit) To UBound(strSplit)
    EmailBody = BuildEmailBody(strSplit(i))   'Sends string with double double quotes - ""ssmith"" - WHY??
   
    If SendValidationEmailExchange(FromEmailAddress, ToEmailAddress, "Employee Validation", EmailBody) Then
        MsgBox "Email has been sent.", vbCritical + vbOKOnly, "Email Has Been Sent'"
                DoCmd.Close acForm, Me.Name
    End If
Next
0
Comment
Question by:ssmith94015
  • 4
  • 2
6 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37744603
Change your split statement to:

strSplit = Split(Replace(strCriteria, chr(39),"") ", ")
0
 

Author Comment

by:ssmith94015
ID: 37744640
I pasted your statement into my code, but it turned red.  It looks ok so am not surewhat I am missing.

Sandra
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 37744690
Sorry about that - I missed a comma:

strSplit = Split(Replace(strCriteria, Chr(39), ""), ", ")
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 61

Expert Comment

by:mbizup
ID: 37744695
If that doesn't work, post the code for your BuildEmailBody function, which may be adding quotes into the resulting string.
0
 

Author Closing Comment

by:ssmith94015
ID: 37745082
Yes, it helpded, thank you.

Sandra
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37745269
Glad that worked out ;-)

<< 'Sends string with double double quotes - ""ssmith"" - WHY?? >>

As to the "WHY?", all the split function does is seperate strings that are delimited by commas (or whatever delimiter is specified in the second argument of the split function).

So "ssmith", "mbizup", "myname", "etc" would be split into array elements as follows, including the quotes:

"ssmith"
 "mbizup"
 "myname"
 "etc"

If you were seeing "double double quotes", I'd have to guess that your function BuildEmailBody at some point adds more quotes.  So you could either resolve this by changing the function to not add quotes, or you could remove quotes from the string before passing it  to the function (as we did here).
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question