Solved

Importing to a MS Access db on a server that doesn't have MS OFFICE

Posted on 2003-12-04
5
301 Views
Last Modified: 2012-05-04
I have created an Access db that has a few macros to automatically delete records, import legacy data, then close itself.  Since I can not put MS Office on our live server I am wondering if I can do this in VB code?

so far for the import section I have written:

dim accImport, db, fso

set accImport = CreateObject("Access.Application")
set fso = CreateObject("Scripting.FileSystemObject")
set db = fso.GetFile("path to my db")

accImport.OpenCurrentDatabase db
accImport.DoCmd.TransferText acImportDelim, "Schema.ini", "table1", "path to the file that gets converted", False, ""

accImport.CloseCurrentDatabase
Set appAccess = Nothing

What I want to know is if this is possible, since I will be manipulating an Access file on a server that doesn't have MS Office installed on it.

Thanks,

ali
0
Comment
Question by:alialipad
  • 3
  • 2
5 Comments
 
LVL 6

Expert Comment

by:rvooijs
ID: 9875060
Hi,

If you don't have Access installed, you can not create an Access.Application object.
The code you have so far won't work then ...

What you can do is create an ADODB.Connection object.
You can use this object to run queries (including append and delete queries) on your database.

I don't have ewxamples nearby so I can''t help you with the exact syntax but you would get
something like this

set objCon = CreateObject("ADODB.Connection")
objCon.Open " ... not sure here ..."

set objCommand = CreateObject("ADODB.Command")
set objCommand.Connection = objCon
objCommand.Execute "SQL statement here ... "

Sorry I can't help you with the exact code, butÍ'm sure this wil get you further.

Robert
0
 

Author Comment

by:alialipad
ID: 9875288
Yeah that puts me on the right track thanks, but now I need to figure out how to get the data in the fields, I am importing a .txt file into the db using "~" as a delimiter.  Should I create an array and split up each line with "~"?

ali
0
 

Author Comment

by:alialipad
ID: 9876650
more the point, I am using this as my looping statement:

While Not textStream.AtEndOfStream
     inLine = Split(textStream.ReadLine, "~")
     Rs.AddNew
     For i = 0 To UBound(inLine) - 1
          Rs.Fields(i).Value = Left(inLine(i), Rs.Fields(i).Size)
     Next i
     Rs.Update
Wend

thanks,

Ali
0
 
LVL 6

Accepted Solution

by:
rvooijs earned 100 total points
ID: 9881981
Hi,

Your code seems OK, what is your question ?

Robert
0
 

Author Comment

by:alialipad
ID: 9882057
as I think about it, I realize that I have arrived at the answer! for you...100 points...ding dong!

ali
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question