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!!!
7 2012 @artemetis
Assuming a precise, 21-digit Format, a code-based approach would look something like this: - Dim MyDB As DAO.Database
-
Dim rstOriginal As DAO.Recordset
-
Dim rstMaster As DAO.Recordset
-
-
Set MyDB = CurrentDb
-
Set rstOriginal = MyDB.OpenRecordset("tblOriginal", dbOpenForwardOnly)
-
Set rstMaster = MyDB.OpenRecordset("tblMaster", dbOpenDynaset)
-
-
With rstOriginal
-
Do While Not .EOF
-
rstMaster.AddNew
-
rstMaster![GroupMaster] = ![GroupMaster]
-
rstMaster![Group4] = Right(![GroupMaster], 3)
-
rstMaster![Group3] = Mid(![GroupMaster], 16, 3)
-
rstMaster![Group2] = Mid(![GroupMaster], 13, 3)
-
rstMaster![Group1] = Mid(![GroupMaster], 10, 3)
-
rstMaster.Update
-
.MoveNext
-
Loop
-
End With
-
-
RefreshDatabaseWindow
-
-
rstOriginal.Close
-
rstMaster.Close
-
Set rstOriginal = Nothing
-
Set rstMaster = Nothing
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!!!
Edited this out so you don't accidentally do it before reading subsequent posts.
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.
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!
NeoPa 32,556
Expert Mod 16PB
This should be an easy SQL job : - INSERT INTO tblMaster
-
(uid,
-
firstName,
-
lastName,
-
groupMaster,
-
group1,
-
group2,
-
group3)
-
-
SELECT uid,
-
firstName,
-
lastName,
-
groupMaster,
-
Mid([groupMaster],10,3) AS group1,
-
Mid([groupMaster],13,3) AS group2,
-
Mid([groupMaster],19,3) AS group3
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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,...
|
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...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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:
...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |