473,799 Members | 3,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting data from a string/field

76 New Member
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: 333444555666777 888999

Looking at the above string:
999 will be inserted into tblMaster.group 3
777 will be inserted into tblMaster.group 2
666 will be inserted into tblMaster.group 1
*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 2029
ChipR
1,287 Recognized Expert Top Contributor
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 Recognized Expert Expert
@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
artemetis
76 New Member
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 Recognized Expert Top Contributor
Edited this out so you don't accidentally do it before reading subsequent posts.
Apr 28 '09 #5
ChipR
1,287 Recognized Expert Top Contributor
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
artemetis
76 New Member
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,579 Recognized Expert Moderator MVP
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
1875
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 second one is used in the first one such as a field. I wrote the scrivi() function to write the record in a file called "archivio.txt" and it works fine. The I wrote the carica() function to load the records that I have placed on the file, but I...
5
2958
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, I have used individual entry fields for each variable. I would now like to use text area boxes to simplify the data entry (this way, data can be produced by another program--FORTRAN, "C", etc.--but analyzed online, so long as it is first...
1
17195
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 part. i’m using Vb.net datagrid as a front end. any assistance appreciated!! :?: --
27
15058
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 from it. Any help will be highly appriciated. Thanks
2
2159
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. Write now, i have emails that i receive in outlook and i want to transfer them into a database. I realized that i could export this. however, the BODY section of the email is exported as one field. As the email i receive is a template and it is...
2
2819
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 C#. The only significant problem that I have encountered in the conversion is this one - extracting an icon from the 'KTEntryPoint' program into the software suite and placing that icon on the PC Desktop.
0
996
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 Dim dc As System.Data.DataColumn
4
2783
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 (fromStop) and its associated driving directions back to a relational database. I have asked my software vendor for solutions but thus far they have not come up with anything. I am totally unfamiliar with XML so I am struggling with how to do this. I have...
4
2322
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: TECH_ACT=2HL91002:TGT_START=12-NOV-07:CAM_CODE=AKJBA:DA=HL:WBS=DES071702: I'd like to extract the element CAM_CODE=AKJBA but the string after the "=" sign can vary in length between rows. Does anyone have a code snippet in their library that might do this ... or is there a built-in function that I...
1
3832
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 thing in the first place). So I removed the assorted taggery from each end, leaving just a big text file taking the following format: ('value', 'value', 'value, 'value'), ('value','value','value','value')...
0
10491
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10268
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
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 we have to send another system
3
2941
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.