Solved

Array is passing values with double double quotes to another procedure

Posted on 2012-03-20
6
413 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
Comment Utility
Change your split statement to:

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

Author Comment

by:ssmith94015
Comment Utility
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
Comment Utility
Sorry about that - I missed a comma:

strSplit = Split(Replace(strCriteria, Chr(39), ""), ", ")
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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
Comment Utility
Yes, it helpded, thank you.

Sandra
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now