Initiate a batch file thru a Access GUI

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating a GUI thru Access. This GUI is not connected to a database.
There is a batch file I like to initiate thru this GUI. For example there
will be a batch file to install a network printer for a user. The user will
press a number or press a printername from a listbox to initiate this batch
file. Is this possible in Access VBA? If it is how should I go about doing
this? I am clueless. I appreciate any help.
The following component is in the GUI:

Building name: Optionboxes
Department name: Listbox
Printer name: Listbox
The user will choose a building name, which has many departments.When the
user choose a department, a list of printers belong to that specific
department will show up in the Printer name listbox. Then the user will
hilite the correct printer name, press either OK or Enter. This will
initiate installing the printer thru the batch file.

Please let me know if this is possible.
Thanks a lot.
 
Hi Thadi,
I'm assuming that you have a button called cmdInstallPrinter on a form:

Private Sub cmdInstallPrinter_Click()
Shell "C:\MyBatchFile.bat", vbMinimizedNoFocus
End Sub

If your listbox value holds the name of the department as text, and is
called lstDeptName then:

Private Sub cmdInstallPrinter_Click()
Dim sPath As String
Dim sDept As String

sPath = "C:\" 'or whatever
sDept = Nz(lstDeptName,"")
If sDept = "" Then Exit Sub
Shell sPath & sDept & ".bat", vbMinimizedNoFocus
End Sub

I hope this helps,
Ed. (Just over Bass straight in Victoria)
 
Back
Top