Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Dos Batch file commands in Access

Status
Not open for further replies.

Sech

Programmer
Jul 5, 2002
137
GB
I am currently creating an Access database to replace an existing batch file that transfers data from one system into text files (Using tto transfer files if that means anything to you). Anyway, the batch file is laid out as below:

@echo off

echo Monthy Download......

REM Batch file to run transfers for monthly download

date /t > "C:\Data\Log.txt"
time /t >> "C:\Data\Log.txt"

RTOPCB /s "C:\Data\Transfers\File1Import.tto" >> "C:\Data\Log.txt"
echo File1 complete
RTOPCB /s "C:\Data\Transfers\File2Import.tto" >> "C:\Data\Log.txt"
echo File2 complete

date /t >> "C:\Data\Log.txt"
time /t >> "C:\Data\Log.txt"

echo Transfer complete.

As you can see, as each of the two files are transferred and at the start and end the command ">> "C:\Data\Log.txt" is used. This copies certain information to a log text file. The information from the tto files includes no of records transferred and confirmation on successful transfer. It looks like the below:

Mon 04/11/2002
9:29

IBM AS/400 Client Access for Windows 95/NT
Version 3 Release 2 Level 0
Transfer data from AS/400
(C) Copyright IBM Corporation and Others 1984, 1995. All rights reserved.
U.S. Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
Licensed Materials - Property of IBM

Transfer file: C:\Data\Transfers\File1Import.tto
Receive completed successfully.
Rows transferred: 47505

IBM AS/400 Client Access for Windows 95/NT
Version 3 Release 2 Level 0
Transfer data from AS/400
(C) Copyright IBM Corporation and Others 1984, 1995. All rights reserved.
U.S. Government Users Restricted Rights - Use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
Licensed Materials - Property of IBM

Transfer file: C:\Data\Transfers\File2Import.tto
Receive completed successfully.
Rows transferred: 26927
Mon 04/11/2002
12:19

Now because I am making the transfer process in access I need to find a way of creating this same log file. Does anyone know how to use the command used in the batch file or an equivalent command inside Access? Someone else I know tried using shell to run the command but this makes an error message appear that is too quick to read.
 
Look up Access Help for File, Open, Close, Freefile, etc. They will give examples of how to handle text file input and output via Access. If you need more help, please feel free to repost with additional questions and/or information.

Good LucK! Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need![thumbsup]
 

RTOPCB /s "C:\Data\Transfers\File1Import.tto" >> "C:\Data\Log.txt"

It's the above command that is being run which grabs the info from the tto file and puts it into the log file. Do you know what this command is and if there is an equivalent command in Access?
 
From HELP:

Dim RetVal
RetVal = Shell("C:\WINDOWS\CALC.EXE", 1) ' Run Calculator

If RetVal is non zero then the process ran correctly, other wise it returns 0. You may need to put your stuff in a string and pass it. The one means run it in a normal window. 0 is hidden, 2 is minimized and 3 is maximized.

Good Luck!


Please remember to give helpful posts the stars they deserve! This makes the post more visible to others in need![thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top