ACC: How to Parse Comma-Separated Text into Multiple Fields (95608)
The information in this article applies to:
- Microsoft Access 1.0
- Microsoft Access 1.1
- Microsoft Access 2.0
- Microsoft Access for Windows 95 7.0
- Microsoft Access 97
This article was previously published under Q95608
Moderate: Requires basic macro, coding, and interoperability skills.
SUMMARY
This article shows you two methods 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.
REFERENCES
For more information about parsing text strings, please see the following
article in the Microsoft Knowledge Base:
115915 Sample Expressions to Extract Portion of Text String
For 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:
148287 ACC2: Neatcod2.mdb Available in Download Center
148402 ACC95: Neatcode.mdb Available in Download Center
Modification Type: | Minor | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbhowto kbProgramming kbusage KB95608 |
---|
|