ACC: How to Parse Comma-Separated Text into Multiple FieldsLast reviewed: August 29, 1997Article ID: Q95608 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. This article demonstrates two methods that you can use to parse comma- separated text in a Text field and to display the text in multiple Text fields. You can use the first method for a Text field that contains two words separated by a comma, for example, a field that contains a last name followed by a first name (Smith, John). The method uses an expression in a query that includes three functions: the Instr() function to search for the comma in the Text field, and the Left$() and Right$() functions to extract the two parts of the Text field. You can use the second method for a Text field that contains more than two words separated by commas, for example, a field that contains a city, a region, and a country (Toronto, Ontario, Canada). This method uses two user-defined functions: a function named CountCSWords() to count the number of comma-separated words in the Text field, and a function named GetCSWord() to return the nth word in the Text field.
MORE INFORMATION
Method 1To parse a Text field that contains two words separated by a comma, follow these steps:
Method 2This part of the article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual. NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access versions 1.x and 2.0. For more information about Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x or the "Building Applications" manual in Microsoft Access version 2.0. To parse a Text field that contains more than two words separated by commas, follow these steps:
REFERENCESFor more information about parsing text strings, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q115915 TITLE : Sample Expressions to Extract Portion of Text StringFor more sample expressions, see the Neatcode.mdb sample databases. For details on how to obtain these, please see the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q148287 TITLE : ACC2: NEATCOD2.MDB Available on MSL ARTICLE-ID: Q148402 TITLE : ACC95: NEATCODE.MDB Available on MSL |
Additional query words: split how to
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |