Add records based on folder names

D

David M C

I would like to append records to my Jobs table based on the name of folders
in the K:\000Projects\GMJobsFile

Each folder is of the format XXXX - Name where XXXX is the JobNumber and
Name is the JobName

My table structure for Jobs is:

JobNumber - primary key number field
JobName - text field

The code will need to check to see if the job number already exists before
adding it to the database. It will also have to parse the string into
JobNumber and JobName. In Java this would be pretty simple. I'm sure it would
be fairly simple in VB as well but could do with some help getting started.

Thanks

Dave
 
A

Alex Dybenko

Hi,
to get folder name - you can use Dir() function, access help has examples
using it

then you have to open recordset, based on your table, set a loop to read
folder names, for each name you first check in record exists using
..FindFirst method, if not - then add folder using:


rst.AddNew
rst!FolderName= ...
rst.Update

I think it is even more easy then in Java <g>

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com
 
D

David M C

Thanks, now I just need to work out how to parse the string. In Java I could
use a String Tokeniser or parse the string manually.

Thanks,

Dave
 
J

John Nurick

If there's guaranteed only to be one " - " sequence in the name, I'd
probably split the string into an array on that:

JobNumber = Split(XXX, " - ")(0)
JobName = Split(XXX, " - ")(1)

If it's possible that there could be more than one " - ", I'd parse the
string manually using Instr(), Left() and Mid().
 

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