473,396 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Extracting data from a string/field

Ok, I'm back again.
I've got the following table.


TableName = tblOriginal
uid - self explanatory
firstName - self explanatory
lastName - self explanatory
groupMaster - contains a numeric string containing 21 digits.

My question surrounds the 'groupMaster' field.
I need the first four groups of three, from the right to be inserted into another existing table, along with the other corresponding fields.

sample string from groupMaster: 333444555666777888999

Looking at the above string:
999 will be inserted into tblMaster.group3
777 will be inserted into tblMaster.group2
666 will be inserted into tblMaster.group1
*all other fields will insert into corresponding names.

TableName = tblMaster
uid
firstName
lastName
groupMaster
group1
group2
group3


As always............thanks in advance!!!
Apr 28 '09 #1
7 2012
ChipR
1,287 Expert 1GB
Hi artemetis,
You want to use the Mid Function (http://office.microsoft.com/en-us/ac...288811033.aspx)
See if you have any specific problems with that.
Apr 28 '09 #2
ADezii
8,834 Expert 8TB
@artemetis
Assuming a precise, 21-digit Format, a code-based approach would look something like this:
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database
  2. Dim rstOriginal As DAO.Recordset
  3. Dim rstMaster As DAO.Recordset
  4.  
  5. Set MyDB = CurrentDb
  6. Set rstOriginal = MyDB.OpenRecordset("tblOriginal", dbOpenForwardOnly)
  7. Set rstMaster = MyDB.OpenRecordset("tblMaster", dbOpenDynaset)
  8.  
  9. With rstOriginal
  10.   Do While Not .EOF
  11.     rstMaster.AddNew
  12.       rstMaster![GroupMaster] = ![GroupMaster]
  13.       rstMaster![Group4] = Right(![GroupMaster], 3)
  14.       rstMaster![Group3] = Mid(![GroupMaster], 16, 3)
  15.       rstMaster![Group2] = Mid(![GroupMaster], 13, 3)
  16.       rstMaster![Group1] = Mid(![GroupMaster], 10, 3)
  17.     rstMaster.Update
  18.     .MoveNext
  19.   Loop
  20. End With
  21.  
  22. RefreshDatabaseWindow
  23.  
  24. rstOriginal.Close
  25. rstMaster.Close
  26. Set rstOriginal = Nothing
  27. Set rstMaster = Nothing
Apr 28 '09 #3
Thanks Folks!

ADezii - how does your code process a blank location, or would it?
For example(s):
"777 999"
"777888 "
where each block of missing values has three null spaces?
I'm seeing that in many of my records.

Thanks again in advance!!!
Apr 28 '09 #4
ChipR
1,287 Expert 1GB
Edited this out so you don't accidentally do it before reading subsequent posts.
Apr 28 '09 #5
ChipR
1,287 Expert 1GB
Sorry, ignore that last suggestion. I though from your example that the items had spaces between them, but a null value is a different story. If you don't use [ code ] tags, your multiple spaces get turned into single spaces.
ADezii's code will still work fine in this case. Blanks are treated much differently from NULLs.
Apr 28 '09 #6
Thanks ChipR.

Yeah, the data that I've been given is a MESS.
In that field of 21, if there is no three digit value, there are three spaces.
It's like 7 fields of three in one field. Grrrrrrrrrrr!
Apr 28 '09 #7
NeoPa
32,556 Expert Mod 16PB
This should be an easy SQL job :
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblMaster
  2.       (uid,
  3.        firstName,
  4.        lastName,
  5.        groupMaster,
  6.        group1,
  7.        group2,
  8.        group3)
  9.  
  10. SELECT uid,
  11.        firstName,
  12.        lastName,
  13.        groupMaster,
  14.        Mid([groupMaster],10,3) AS group1,
  15.        Mid([groupMaster],13,3) AS group2,
  16.        Mid([groupMaster],19,3) AS group3
Apr 29 '09 #8

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

Similar topics

2
by: Aleander | last post by:
Hi! I have to write the records of a vector in a file, e and then open this file to extract the record to refill the vector. My program has two class: Visita(Appointment) and Data(date). The...
5
by: Michael Hill | last post by:
Hi, folks. I am writing a Javascript program that accepts (x, y) data pairs from a text box and then analyzes that data in various ways. This is my first time using text area boxes; in the past,...
1
by: v0lcan0 | last post by:
Any help on extracting the time part from the datetime field in SQL database. even though i had entered only the time part in the database when i extract the field it gives me only the date...
27
by: gRizwan | last post by:
Hello all, We have a problem on a webpage. That page is sent some email data in base64 format. what we need to do is, decode the base64 data back to original shape and extract attached image...
2
by: Branden | last post by:
hi guys, i was wondering if it is possible to extract selected words in a field to be put in different fields automatically. Do i have to write the code in vb? This is what im trying to do....
2
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to...
0
by: glenn | last post by:
Hello, I am using the following code to pull data from my dataset in Page_Load Dim str As String Dim ds As System.Data.DataSet Dim dt As System.Data.DataTable Dim dr As System.Data.DataRow...
4
by: Debbiedo | last post by:
My software program outputs an XML Driving Directions file that I need to input into an Access table (although if need be I can import a dbf or xls) so that I can relate one of the fields...
4
by: Keith Wilby | last post by:
On a bit of a no-brainer with this. I have a field containing composite data which is imported from another system. Here's a sample: ...
1
by: TYR | last post by:
I have a large dump file that originated in a MySQL db; I need to get it into an SQLite file. Various options are suggested around the web; none of them seem to work (most failing to import the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.