473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Command Line Access

I have written a script to back/compact/repair an msaccess db it works
fine however i would like to determine if access successfully compact
and repaired the database. How could i do this?

I am running Access2k

Here is the batch script:

@echo off

copy "w:\l&c\stats\StatsConvert2k.mdb" c:\backups\stats\%date:~-4,
4%%date:~-7, 2%%date:~0,2%StatsConvert2k.mdb

IF ERRORLEVEL = 1 GOTO COPYERR

REM This compacts and repairs the live database
START "" /B /MAX /REALTIME /WAIT
c:\progra~1\micros~3\Office\msaccess.exe
"w:\l&c\stats\StatsConvert2k.mdb" /COMPACT /WRKGRP
c:\progra~1\common~1\system\System.mdw

echo Task complete
@echo %date:~-4, 4%%date:~-7, 2%%date:~0,2% STATS BACKED
UP/COMPACTED/REPAIRED >c:\backups\log.txt
exit

:COPYERR
echo Error making backup compact/repair aborted
echo %date:~-4,4%%date:~-7,2%%date:~0,2% COPY FAILED >>
c:\backups\log.txt

Jul 31 '06 #1
5 4440
I don't understand the question. If it errors out, your log file will
report that.

nexes wrote:
I have written a script to back/compact/repair an msaccess db it works
fine however i would like to determine if access successfully compact
and repaired the database. How could i do this?

I am running Access2k

Here is the batch script:

@echo off

copy "w:\l&c\stats\StatsConvert2k.mdb" c:\backups\stats\%date:~-4,
4%%date:~-7, 2%%date:~0,2%StatsConvert2k.mdb

IF ERRORLEVEL = 1 GOTO COPYERR

REM This compacts and repairs the live database
START "" /B /MAX /REALTIME /WAIT
c:\progra~1\micros~3\Office\msaccess.exe
"w:\l&c\stats\StatsConvert2k.mdb" /COMPACT /WRKGRP
c:\progra~1\common~1\system\System.mdw

echo Task complete
@echo %date:~-4, 4%%date:~-7, 2%%date:~0,2% STATS BACKED
UP/COMPACTED/REPAIRED >c:\backups\log.txt
exit

:COPYERR
echo Error making backup compact/repair aborted
echo %date:~-4,4%%date:~-7,2%%date:~0,2% COPY FAILED >>
c:\backups\log.txt
Jul 31 '06 #2
It only will report on a copy not if access errors for some reason
whenever i try and put an if errorlevel for the compact of the database
it does not show an error if access failed.

ManningFan wrote:
I don't understand the question. If it errors out, your log file will
report that.

nexes wrote:
I have written a script to back/compact/repair an msaccess db it works
fine however i would like to determine if access successfully compact
and repaired the database. How could i do this?

I am running Access2k

Here is the batch script:

@echo off

copy "w:\l&c\stats\StatsConvert2k.mdb" c:\backups\stats\%date:~-4,
4%%date:~-7, 2%%date:~0,2%StatsConvert2k.mdb

IF ERRORLEVEL = 1 GOTO COPYERR

REM This compacts and repairs the live database
START "" /B /MAX /REALTIME /WAIT
c:\progra~1\micros~3\Office\msaccess.exe
"w:\l&c\stats\StatsConvert2k.mdb" /COMPACT /WRKGRP
c:\progra~1\common~1\system\System.mdw

echo Task complete
@echo %date:~-4, 4%%date:~-7, 2%%date:~0,2% STATS BACKED
UP/COMPACTED/REPAIRED >c:\backups\log.txt
exit

:COPYERR
echo Error making backup compact/repair aborted
echo %date:~-4,4%%date:~-7,2%%date:~0,2% COPY FAILED >>
c:\backups\log.txt
Jul 31 '06 #3
Basically i need a way to get an errorlevel from access whenever it
fails to compact

nexes wrote:
It only will report on a copy not if access errors for some reason
whenever i try and put an if errorlevel for the compact of the database
it does not show an error if access failed.

ManningFan wrote:
I don't understand the question. If it errors out, your log file will
report that.

nexes wrote:
I have written a script to back/compact/repair an msaccess db it works
fine however i would like to determine if access successfully compact
and repaired the database. How could i do this?
>
I am running Access2k
>
Here is the batch script:
>
@echo off
>
copy "w:\l&c\stats\StatsConvert2k.mdb" c:\backups\stats\%date:~-4,
4%%date:~-7, 2%%date:~0,2%StatsConvert2k.mdb
>
IF ERRORLEVEL = 1 GOTO COPYERR
>
REM This compacts and repairs the live database
START "" /B /MAX /REALTIME /WAIT
c:\progra~1\micros~3\Office\msaccess.exe
"w:\l&c\stats\StatsConvert2k.mdb" /COMPACT /WRKGRP
c:\progra~1\common~1\system\System.mdw
>
echo Task complete
@echo %date:~-4, 4%%date:~-7, 2%%date:~0,2% STATS BACKED
UP/COMPACTED/REPAIRED >c:\backups\log.txt
exit
>
:COPYERR
echo Error making backup compact/repair aborted
echo %date:~-4,4%%date:~-7,2%%date:~0,2% COPY FAILED >>
c:\backups\log.txt
Jul 31 '06 #4
I think I would create an mdb that includes the code to do
repair/compact your database. Then call this mdb from your batch file.
That should give you more control over the error handling.

Jul 31 '06 #5
"nexes" <ne******@gmail.comwrote in
news:11**********************@b28g2000cwb.googlegr oups.com:
It only will report on a copy not if access errors for some reason
whenever i try and put an if errorlevel for the compact of the
database it does not show an error if access failed.

ManningFan wrote:
>I don't understand the question. If it errors out, your log file
will report that.

nexes wrote:
I have written a script to back/compact/repair an msaccess db it
works fine however i would like to determine if access successfully
compact and repaired the database. How could i do this?

I am running Access2k

Here is the batch script:

@echo off

copy "w:\l&c\stats\StatsConvert2k.mdb" c:\backups\stats\%date:~-4,
4%%date:~-7, 2%%date:~0,2%StatsConvert2k.mdb

IF ERRORLEVEL = 1 GOTO COPYERR

REM This compacts and repairs the live database
START "" /B /MAX /REALTIME /WAIT
c:\progra~1\micros~3\Office\msaccess.exe
"w:\l&c\stats\StatsConvert2k.mdb" /COMPACT /WRKGRP
c:\progra~1\common~1\system\System.mdw

echo Task complete
@echo %date:~-4, 4%%date:~-7, 2%%date:~0,2% STATS BACKED
UP/COMPACTED/REPAIRED >c:\backups\log.txt
exit

:COPYERR
echo Error making backup compact/repair aborted
echo %date:~-4,4%%date:~-7,2%%date:~0,2% COPY FAILED >>
c:\backups\log.txt
Assuming a modern version of Access I would try something like this more
or less air code:

Public Sub CompactExternalFile(ByVal dbname As String)
Dim a As Access.Application
Dim TempName As String
Set a = New Access.Application
TempName = Replace(dbname, ".", Format(Now(), "YYYYMMDDHHNNSS."))
With a
If .CompactRepair(dbname, TempName, True) Then
Kill dbname
Name TempName As dbname
Else
On Error Resume Next
Kill TempName
On Error GoTo 0
MsgBox "Check logfile", vbCritical, "Compact Failed"
End If
.Quit
End With
Set a = Nothing
End Sub

Sub temp2()
CompactExternalFile "northwind.mdb"
End Sub

--
Lyle Fairfield
Jul 31 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Klaus Baumgarten | last post by:
Hi! I' m sitting here now for days and I still get no conclusion on my problem. I have an MS ACCESS .mdb File and I would like to export it with dtswiz.exe (from MS SQL Utility Tools) via...
6
by: Paul Deverson | last post by:
I'm a newbie to MySQL and am really confused about when I should be using the Command Line Client and when the DOS prompt. I'm using Windows XP and I've just installed MySQL 4.1.10. I can use...
10
by: Steve | last post by:
Is there anyone with experience using the Winzip command line add-in? I can't get it to create the zip file with a space in the file name. Using: RetValue = Shell("C:\winzip\wzzip.exe...
1
by: Dennis Gaida | last post by:
Hi there, I want to upload some exported reports to a FTP Server, for this I use a command line FTP utility. My Database sits in C:\Documents and Settings\Dennis\My Documents\Database The FTP...
3
by: Glenn | last post by:
We want to deploy a change to a database with minimal effort by the users. I see how to open an Access database from the command line, but can you then issue DDL statements through a command line? ...
3
by: Chris | last post by:
Hello all. I have a database that I use to send email updates to people. Everything is working fine, but one suggestion I keep getting is to add a link to the automatic emails that will open up the...
5
by: randyelliott | last post by:
Good Day, I have a MS Access (Access 2000 now upgraded to 2003) database that tracks customer information. One function of this database is to create an encrypted license file for our software,...
10
by: Mandy | last post by:
I have a command line tool that I would like to run from my .NET web application using System.Diagnostics.ProcessStartInfo. I run cmd.exe with this and then pass the command to run the tool as an...
1
by: amirmira | last post by:
I would like to set command line arguments to a service at install time. I need to do this because I need to get information from different registry locations depending on my command line argument....
2
by: tonytony24 | last post by:
Hi All: I was wondering if there's a simple way to call a MS Access Module through either Command Prompt MS Script any other way... Thanks for the response.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.