A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

# in table



 
 
Thread Tools Display Modes
  #1  
Old November 25th, 2009, 08:07 PM posted to microsoft.public.access.queries
instereo911 via AccessMonster.com
external usenet poster
 
Posts: 33
Default # in table

Hi,

I have a table w/ multiple values on one column seperated out by a ";#" sign.


Example:
State Number
;#Central;#COVA;# 1


Ideally, what i want to do is the following

State Number
Central 1
COVA 1

So it breaks it out to two different rows for each of the ;#

Is this possible? I hope so because I don't want to redo everything..


Thanks again everyone !!!

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1

  #2  
Old November 25th, 2009, 09:32 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default # in table

On Wed, 25 Nov 2009 20:07:20 GMT, "instereo911 via AccessMonster.com"
u27979@uwe wrote:

Hi,

I have a table w/ multiple values on one column seperated out by a ";#" sign.


Example:
State Number
;#Central;#COVA;# 1


Ideally, what i want to do is the following

State Number
Central 1
COVA 1

So it breaks it out to two different rows for each of the ;#

Is this possible? I hope so because I don't want to redo everything..


Thanks again everyone !!!


Possible but tedious. It will probably be easiest if you write a little VBA
function to help parse it out:

Public Function GetState(strIn As String, iPos As Integer, _
Optional strDelim As String = ";#") As String
Dim States() As String
States = Split(strIn, strDelim)
If UBound(States) = iPos Then
GetState = States(iPos)
Else
GetState = ""
End If
End Function

You can then run an Append query using GetState([fieldname], 1) to pull out
the first value, 2 the next, etc.; use a criterion of "" on the calculated
field to return only the non-empty states. Or, you could use VBA to loop
through the string and append records to an open recordset.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:24 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.