Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2004

Tip: Looking for answers? Try searching our database.

Send Access Data to a Batch file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Build or Die - 28 Aug 2004 21:17 GMT
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
John Nurick - 29 Aug 2004 07:48 GMT
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: "

>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
[quoted text clipped - 22 lines]
>    SendKeys "tbl.Project.ProjectYear" {ENTER} "tbl.Project.ProjectID" {ENTER}
>End Sub

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.