parse through one access field and create 3 fields

M

Mary

Hello,
I really need help. I have a link table called mail with a field called
content. The field has the following data the body of outlook mail:
Owner=tina
Company=IBM
Job=accounting.
I have created another table called newtable with the following fields:
owner, company and job
I would like to have a vb script that will parse through the mail table
content field and enter the result into the newtable . The result should be
in the newtable fields should be
Owner company Job
Tina IBM accounting.

Please please any help will be greatly appreciated.
 
D

Daniel Pineault

1st off, if you are truly looking for a vbscript solution you need to repost
your question in a vbscript forum.

If as the rest of your post suggests looking for an access solution then you
are looking for a vba solution.

As such you could use the split function to seperate to content field value
into useful pieces. How to haddle in more detail depends on the field
itself, but basically

split([content],"=") should get you going in the right direction.

Then with your values seperated...you can easily append the data in a table.
You can find example of this by searching this forum or google group for
terms like" ms access vba append recordset
 
P

Paolo

Hello Mary,
here's the code for doing what you ask:

Set rec = CurrentDb.OpenRecordset("select * from mail", dbOpenDynaset)
set rec_trg=currentdb.openrecordset("select * from newtable",dbopendynaset)
do while not rec.eof
tmp = Split(rec![content], "=")
rec_trg.addnew
For i = 1 To 3
tmp1 = Split(tmp(i), " ")
if i=1 then
rec_trg![owner]=tmp1(0)
elseif i=2 then
rec_trg![company]=tmp1(0)
elseif i=3 then
rec_trg![job]=tmp1(0)
endif
Next i
rec_trg.update
rec.movenext
loop
rec.close
rec_trg.close

I didn't test the code but it should work.

Merry Christmas, Paolo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top