Wrap String

Posted on 2007-04-05
Last Modified: 2012-05-05
Hi: This is the the string.
TxtString1 = "DBTRADDR" & "," & mAddress1A & "," & mAddress1B & "," & mCity1 & "," & mState1 & "," & mZip1 _
& "," & """"

And this is the result
DBTRADDR,100 E GRAND BLVD STE 100,"",CORONA,CA,928792222,""

My question is how to i put a double quotation mark around each field. Even if there is a value or no value in it. It must be wrap with double quotation mark like that. I try it but it not wrap the fields which have value in it.
DBTRADDR,"100 E GRAND BLVD STE 100","","CORONA","CA","928792222",""


TxtString1 = "DBTRADDR" & "," & iif (IsNull(mAddress1A), chr(34) & chr(34), mAddress1A) & "," &  iif (IsNull(mAddress1B), chr(34) & chr(34), mAddress1B) & "," &  iif (IsNull(mCity1), chr(34) & chr(34), mCity1) & "," &  iif (isNull(mState1) , chr(34) & chr(34), mState1) & "," &  iif (isNull(mZip1), chr(34) & chr(34), mZip1) _
& "," & """"
Question by:mustish1
1 Comment

Accepted Solution

kingtam2000 earned 500 total points
ID: 18861864
If you want to put quotation marks around the fields, then you would add "" (double quotes) before and after each field.  So, taking your string (I'm not sure if you want to put quotation marks around DBTRADDR, I'm assuming you don't):
TxtString1 = "DBTRADDR" & ", """ & mAddress1A & """, """ & mAddress1B & """, """ & mCity1 & """, """ & mState1 & """, """ & mZip1 & """, """ & """"
You can join up the first and last strings if you wanted to so it would be:
TxtString1 = "DBTRADDR, """ & mAddress1A & """, """ & mAddress1B & """, """ & mCity1 & """, """ & mState1 & """, """ & mZip1 & """, """""

If you wanted something different or need more help, just post a comment.

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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