Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / March 2008

Tip: Looking for answers? Try searching our database.

Separate Data

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rml - 24 Mar 2008 18:59 GMT
I have a table with a field that has data that looks like the following:

N0345, H4354, 48574, 48577

How can I create a query that would separate that data into their own fields?

Field one would have N0345 the next would have H4354 etc...

Thanks.
akphidelt - 24 Mar 2008 19:31 GMT
Look up Crosstab queries

> I have a table with a field that has data that looks like the following:
>
[quoted text clipped - 5 lines]
>
> Thanks.
John Spencer - 24 Mar 2008 20:49 GMT
This can be done with difficulty.

What you really need to do is to store the values in a table with one row
for each of the values.

What is the maximum number of values that might be stored.

I would use a custom vba function to do this.

SELECT getSplit([MultiField],0) as TheFirst
, getSplit([MultiField],1) as TheSecond
, getSplit([MultiField],2) as TheThird
, getSplit([MultiField],3) as TheFourth
FROM YourTable

"UNTESTED FUNCTION follows.  Copy and paste this into a VBA module and save
it.
Public Function getSplit(TheString, iPos)
Dim vAr as Variant

   If Len(TheString & "") = 0 Then
     getSplit = Null
  Else
     vAr = Split(theString, ",")
     If iPos <= UBound(vAr) Then
        getSplit = vAr(iPos)
    Else
       getSplit = Null
    End if

End Function

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

>I have a table with a field that has data that looks like the following:
>
[quoted text clipped - 6 lines]
>
> Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.