I would like some help with a database that I'm working on. The database is a pretty basic interface that runs a number of functions by clicking different command buttons along the side. The commands are reasonably simple but I'm not great with VBS/VBA. Someone else built the database before I started working here!
I've written a Powershell script which filters and sorts data into a more readable list. Because I'm slightly more familiar with it than Visual Basic, I wanted to just keep that script and run it through Access using VB. The script works fine but I'm trying to add it to the database as another clickable 'command button'. The VBS script I have to run the PS script is:
Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.Run("powershell.exe -noexit P:\TestScripts\runtest.ps1")
Again, this code runs fine, it opens Powershell command line, prompts the user for info and runs the script. When I add it to Access as an 'Event Procedure' (in the property sheet for the command button, I have "On Click" set to "Event Procedure" so I could add the VBS code) and then work through the database, there's no response when I press that command. Do I need to change my VBS script? I'd assume that there wasn't much difference for a Run command between VBS and VBA. The code in Access looks like:
Private Sub Command58_Click()
Set objShell = Wscript.CreateObject("Wscript.Shell")
objShell.Run ("powershell.exe -noexit P:\TestScripts\runtest.ps1")
End Sub
Apologies for the long message, I just wanted to try and give as much info as possible! I'd appreciate any help. There may very well be a simple solution to all this but my lack of experience is definitely holding me back! Thanks.
-J