Send Access Data to a Batch file

G

Guest

I have a batch file that opens a Windows Explorer window to a path based on
two typed-in parameters. I would like to add a command button to my access
form that runs this batch file and enters the two required parameters from
data located in the access form. (confused yet?) I'm using the shell command
to run the batch, but then I get stuck. I want to use the "SendKeys"
command, but I don't think that the data can vary. Can anyone help me out?
Thanks, -Steve

Batch file content:

@ECHO OFF
CLS

ECHO ENTER YEAR
SET /p T1=
ECHO ENTER PROJECT NUMBER
SET /p T2=

EXPLORER/E,C:\%t1%\%t2%

Access Event Content: (so far)

Private Sub Open_C_Drive_File_Click()
Shell ("C:\Open_Explorer.bat")
SendKeys "tbl.Project.ProjectYear" {ENTER} "tbl.Project.ProjectID" {ENTER}
End Sub
 
J

John Nurick

Hi

The normal way of passing parameters to a batch file is to include them
on the command line and reference them in the file as %1, %2 etc. Is
there some special need to use environment variables that's not apparent
from what you've posted?

Assuming not, then the only "functional" line in the batch file is the
call to Explorer.exe, so all you need is something like this. It assumes
the year is displayed in a textbox on the form called txtYear, and the
project number in txtPrjNum

With Me
Shell "Explorer.exe /E, C:\" & .txtYear.Value _
& "\" & .txtPrjNum.Value
End With

Even if you really need to use a batch file to do cunning stuff you
haven't shown us, pass the data in the Shell() statement. If you want
the same batch file to work from VBA but still to prompt the user for
parameters that haven't been supplied on the command line, use something
like this
@ECHO OFF
ECHO.
SET T1=%1
SET T2=%2

IF !%T1%!==!! SET /p T1="Please enter year: "
ECHO.
IF !%T2%!==!! SET /p T2="Please enter project number: "



On Sat, 28 Aug 2004 13:17:07 -0700, Build or Die <Build or
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top