Solved

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

Posted on 2003-12-04
5
305 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Monitor input from a computer is usually nothing special.  In this instance it prevented anyone from using the computer.  This was a preconfiguration that didn't work.
Make the most of your online learning experience.
Six Sigma Control Plans
Introduction to Processes

695 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