Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 1st, 2006, 03:48 AM
Authorized User
 
Join Date: Apr 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lizhaskin
Default Combining Text Fields

Hi,
Can anyone help me?

I need to combine an undetermined number of text fields into one field in a query. In other words, if I have the following:

ID Name
1 Liz
2 Tertia
3 Peter
4 Paul
5 Sue

I would like to conbine the Name field into one:

Liz ; Tertia ; Peter : Paul ; Sue

There is no definate number of names, so I would need an expression that will combine all Names in the row with a ; in between.
Is this possible?
Thanks
Liz


 
Old May 1st, 2006, 06:15 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Yes.

It looks like you are combining all the names in a column, not a row. Where are you getting the data? Is it a query result? Please explain the origin of the data. You can loop through the recordset and then concatenate all the names in a variable like this:

sNamesVar = sNamesVar & "; " & objRS.Names

Or something like that. If you do this after looping through each record, then it will build the string you have.

You may want to look up "Regular Expressions" on msdn for information on concatenating text strings.

HTH


mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
populating online text fields etc hamilton C# 2 June 20th, 2007 09:16 AM
Calculating text fields jayman Classic ASP Basics 13 March 6th, 2006 05:27 AM
specifying number of text fields Astro VB How-To 64 August 9th, 2005 08:02 PM
MySQL Text Fields MAtkins General .NET 0 May 27th, 2005 03:17 PM
Insert two fields or more into one Text Object Itai Crystal Reports 2 May 25th, 2005 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.