Re: Automatic Scheduled Import
- From: John Nurick <j.mapSoN.nurick@xxxxxxxxxxxxxx>
- Date: Wed, 13 Apr 2005 07:26:59 +0100
Hi Mark,
There are several ways. If it's a matter of running a simple append
query to import the data I'd write a script using the DAO library to
create and execute the query without using Access itself; this avoids
all the potential complications of using Access for unattended server
operation which it's not designed for (and also saves the cost and
trouble of installing Access on the server). Here's an example procedure
which can be used in a VBScript:
Sub TextImport(MDBFile, TableName, FolderPath, _
TextFileName, Extension)
'VBS to import data from a CSV file into a table in an MDB file
'Folderpath must end with \ (e.g. "C:\Folder\Sub folder\")
'TextFileName is just the name (e.g. "MyFile")
'Extension must not include the . (e.g. "txt")
Dim oJet ' DAO.DBEngine
Dim oDB ' DAO.Database
Dim strSQL ' String
Set oJet = CreateObject("DAO.DBEngine.36")
Set oDB = oJet.OpenDatabase(MDBFile)
strSQL = "INSERT INTO " & TableName _
& " SELECT * FROM [Text;HDR=Yes;Database=" & FolderPath _
& ";].[" & TextFileName & "#" & Extension & "];"
oDB.Execute strSQL, 128 'dbFailOnError
oDB.Close
End Sub
Having got the VBScript working in a test setup, install it on the
server and set up a Scheduled task to run it whenever needed. If you
want to log the the operation of the script, you can get the number of
records appended by using
oDB.RecordsAffected
after the .Execute and send it to the server's event log or somewhere.
On Tue, 12 Apr 2005 09:31:01 -0700, "Mark Senibaldi"
<MarkSenibaldi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>Hi,
>I have a database on a shared server. Is there any way so that every day at
>1:00pm the database will automatically run a macro which so happens to import
>data into the database?
>
>Thanks,
>Mark
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
.
- References:
- Automatic Scheduled Import
- From: Mark Senibaldi
- Automatic Scheduled Import
- Prev by Date: Re: search, transfer file & open form in one macro???
- Next by Date: Re: MISSING ZERO IN IMPORTED EXCEL DATA 104.10 = 104.1 ????HOW CAN
- Previous by thread: Automatic Scheduled Import
- Next by thread: jet db on linux file server problems
- Index(es):
Relevant Pages
|
Loading