Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
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 …

910 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

23 Experts available now in Live!

Get 1:1 Help Now