I am trying to figure out why the below VB Code is not working. I do not get any errors just an hour glass for a few seconds and then nothing. I tested the SQL script and it returns the correct data. I also tested the VB Code without the SQL script and just imputing the string and it works.
DOESN’T WORK:
Private Sub RDPSystemInfo_Click()
On Error GoTo Err_RDPSystemInfo_Click
Dim WshShell
Dim stAppName As String
stAppName = “SELECT systeminformation.[RDPProfile] ” & _
“FROM systeminformation ” & _
“WHERE systeminformation.[AccountNumber]=2000;”
Set WshShell = CreateObject(“WScript.Shell”)
WshShell.Run “mstsc.exe ” & stAppName & “”
Exit_RDPSystemInfo_Click:
Exit Sub
Err_RDPSystemInfo_Click:
MsgBox Err.Description
Resume Exit_RDPSystemInfo_Click
End Sub
WORKS:
Private Sub RDPSystemInfo_Click()
On Error GoTo Err_RDPSystemInfo_Click
Dim WshShell
Dim stAppName As String
stAppName = “G:\RDPConnections\CooperPeds.rdp”
Set WshShell = CreateObject(“WScript.Shell”)
WshShell.Run “mstsc.exe ” & stAppName & “”
Exit_RDPSystemInfo_Click:
Exit Sub
Err_RDPSystemInfo_Click:
MsgBox Err.Description
Resume Exit_RDPSystemInfo_Click
End Sub