473,473 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Splitting fields

1 New Member
Hello,

I am working on a query in Access 2003. I have multiple rows of data like below:

Ord # date description time
1 11/7/06 chocolate 01:00,09:00,18:00

Is there a way in Access to have the information under time split into another field if there is a comma after the number?

Possibly have the times after the first time in the column split into time1, time2, (or more if there are more times) having the times move into a new column if there are more than one time in the field?

I hope that makes sense.

Thanks,
Cynthia
Nov 8 '06 #1
2 1766
Killer42
8,435 Recognized Expert Expert
Do you mean to actually change the way the data is stored in your table, or do you just want to look at it a different way?
Nov 8 '06 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
Create new table as follows:

tblTime
TimeValue (Text Datatype)
Ord # (Foreign Key Ref to other table)

Set up a fully cascading relationship between this table and your original table on [Ord#].

You will need to put this function in a module and call in somewhere in form code. Set up a dummy form with a command button if no code available. Make your query the record source of the form and put the Time field on the form and call it txtTime. You will also need to put the [Ord#] field on the form. See underneath for command button code.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Function splitTimes(strTime As String, orderNo As Long)
  3. Dim x As Variant
  4. Dim i As Long
  5.  
  6.     x = Split(strTime, ",")
  7.     For i = 0 To UBound(x)
  8.        DoCmd.RunSQL "INSERT INTO tblTime (TimeValue, [Ord#]) " & _
  9.              "VALUES ('" & x(i) & "'," & OrderNo & ");"
  10.     Next i
  11.  
  12. End Sub
  13.  
  14.  
To call the function...

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub CommandButtonName_OnClick()
  3. Dim rs As Recordset
  4.  
  5.   Set rs=Me.RecordsetClone
  6.  
  7.   rs.MoveFirst
  8.   Do Until rs.EOF
  9.     splitTimes(Me.txtTime, Me.[Ord#])
  10.     rs.MoveNext
  11.   Loop
  12.  
  13.   rs.Close
  14.   Set rs = Nothing
  15.  
  16. End Sub
  17.  
  18.  


Hello,

I am working on a query in Access 2003. I have multiple rows of data like below:

Ord # date description time
1 11/7/06 chocolate 01:00,09:00,18:00

Is there a way in Access to have the information under time split into another field if there is a comma after the number?

Possibly have the times after the first time in the column split into time1, time2, (or more if there are more times) having the times move into a new column if there are more than one time in the field?

I hope that makes sense.

Thanks,
Cynthia
Nov 8 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Angelo Secchi | last post by:
Hi, I have string of numbers and words like ',,,,,,23,,,asd,,,,,"name,surname",,,,,,,\n' and I would like to split (I'm using string.split()) it using comma as separator but I do not want to...
7
by: qwweeeit | last post by:
Hi all, I am writing a script to visualize (and print) the web references hidden in the html files as: '<a href="web reference"> underlined reference</a>' Optimizing my code, I found that an...
1
by: Earl Anderson | last post by:
I have imported an Excel worksheet into A97/WinXPH which had the new employees names in one field ( in a Last Name,First Name configuration). I wanted to split that one field ( ) into two...
2
by: Gary Lynch | last post by:
I am looking for a simple solution to a recurrent problem with imported data in Access 97. The example below is a simplification of a problem with a much larger database. Let's say I start out...
4
by: JeffM | last post by:
Quick C# question: I have comma delimited values in a string array that I want to pass to seperate variables. Any tips on splitting the array? Thanks in advance! JM
2
by: Trint Smith | last post by:
Ok, My program has been formating .txt files for input into sql server and ran into a problem...the .txt is an export from an accounting package and is only supposed to contain comas (,) between...
20
by: Opettaja | last post by:
I am new to c# and I am currently trying to make a program to retrieve Battlefield 2 game stats from the gamespy servers. I have got it so I can retrieve the data but I do not know how to cut up...
1
by: sadiewms | last post by:
Hello! I have a flat file that I'm trying to get into a relational Access 2003 DB. One of the fields in the flat file has a list of names separated by ";". I'd like to loop through them and...
2
by: Matt | last post by:
Hi, I'm ridiculously new to Access (about a week!) so please be patient! My database is a record of British Standards. Each has a unique identifier. Some are split into parts. I would like...
4
by: The Facilitator | last post by:
Well, Outlook seems to be making my life more and more challenging. Categories are added in one field and are delimmited via comma. Have three questions on this one... The first is right now...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.