Solved

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

Posted on 2003-12-04
5
298 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 48
create an incrementing variable name AutoHotKey 5 58
wordmultiple challenge 12 93
Currency Conversion? 1 39
This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now