Solved

Array is passing values with double double quotes to another procedure

Posted on 2012-03-20
6
416 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

726 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