batch import data from txt to a MS Access 2007 field

I have a MS Access 2007 database with a list of thousands of people, that includes their id number, name, status, link to photo file location, etc.  I took a couple hundred pictures that had to wait to be entered into the "photo" field, because I had no id numbers for them at the moment.  Now, I do have a txt file with a list of a couple hundred files that are named after their id numbers.  It looks like this:

007733.jpg
007755.jpg
008010.jpg
etc.

What I want to do is follow a few steps in Access 2007 (compacted into a macro or a couple of functions) that would:

1. read the txt file
2. find an entry for each id number listed, by taking, say, 007733 out of 007733.jpg and looking it up in the "idnumber" column
3. update those couple hundreds of entries so that, for instance, an entry with 007733 in the "idnumber" column it would have: N:\photos\007733.jpg in the "photo column

You suggestions are most welcome!
lolekbolekAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Is this a one time thing? Sounds like it, and if so then first import the Text file into Access using the Get External Data tab. When you do that, you should have a single column table. Now add a second column to that table named "IDNumber", and run this code:

CurrentDb.Execute "update YourTable set IDNumber=Left(YourTextField, Len(YourTextField)-4)"

You can run this from the Immediate window, of from the click event of a button, etc. You'd obviously have to change the Table and Field names to match your own.

Now update your "live" table to show the Photo field:

Currentdb.Execute "UPDATE YourLiveTable SET YourImageField='F:\Photos\" & YourImportTable.ImageName & "'"

You can do most this in the query interface as well - just import the table, and run the first code above in the Immediate window, then create a new query with your two tables, and "join" them on the IDNumber field, and the "ID" field of your existing table. Then select to create an Update query, and add this expression to the Criteria row of the YourImageField column:

"F:|Photos\" & [YourImportTable].FirstTextField
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lolekbolekAuthor Commented:
Thank you, Scott.  I usually never have to work with Access, so if you could give me an idea of what the "immediate window" means or how to run your code from it (i.e., what menu options or toolbar buttons to use before getting to a place where I can paste the code), that would be peachy.
0
MacroShadowCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Scott McDaniel (Microsoft Access MVP - EE MVE ) (http:#a40200809)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

MacroShadow
Experts-Exchange Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.