Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 Access 2000 ShellExecute Issue

Status
Not open for further replies.

kermitforney

Technical User
Mar 15, 2005
374
0
0
US
Having a n issue with ShellExecute where the file is being deleted instead of opened. Usually during this process a SQL Server Stored Procedure is called followed by an Excel file being opened, but for some reason the file is being deleted.
Not sure why and unfortunately I am not too familiar with VBA.
Any help would be greatly appreciated.

Code:
Private Sub Command0_Click()
Dim cmd As ADODB.Command
Dim prm As ADODB.Parameter
Dim strOpComp As String
Dim strDiv As String
Dim i As Variant

strOpComp = "ALL"
strDiv = "ALL"

DoCmd.Hourglass True
Set cmd = New ADODB.Command

If Me.frmFilter.Value = 2 And Me.lstOperatingCompanies.ItemsSelected.Count > 0 Then
    strOpComp = ""
    For Each i In Me.lstOperatingCompanies.ItemsSelected
        strOpComp = strOpComp + Me.lstOperatingCompanies.ItemData(i) + ","
    Next i
End If

If Me.frmFilter.Value = 3 And Me.lstDivisions.ItemsSelected.Count > 0 Then
    strDiv = ""
    For Each i In Me.lstDivisions.ItemsSelected
        strDiv = strDiv + Me.lstDivisions.ItemData(i) + ","
    Next i
End If


With cmd
    .ActiveConnection = CurrentProject.Connection
    .CommandTimeout = 1200
    .CommandType = adCmdStoredProc
    .CommandText = "stpItemSalesByDateRange_XLS"
    Set prm = .CreateParameter("@StartDate", adDate, adParamInput, , Me.txtStart.Value)
    .Parameters.Append prm
    Set prm = .CreateParameter("@EndDate", adDate, adParamInput, , Me.txtEnd.Value)
    .Parameters.Append prm
    Set prm = .CreateParameter("@OperatingCompanies", adVarChar, adParamInput, 300, strOpComp)
    .Parameters.Append prm
    Set prm = .CreateParameter("@Divisions", adVarChar, adParamInput, 300, strDiv)
    .Parameters.Append prm
    .Execute
End With

DoCmd.Hourglass False
'ShellExecute 0, vbNullString, "\\SNLSQL001\ATA\IT\SalesDetail.xls", vbNullString, vbNullString, vbNormalFocus
ShellExecute 0&, vbNullString, "\\SNLSQL001\ATA\IT\SalesDetail.xls", vbNullString, vbNullString, SW_SHOWNORMAL

End Sub
 
False alarm!!!

The file was being killed via XP_CMDSHELL.
 
Just a heads up: the VB in Access is VBA, not VB6 (no matter what Help About tries to tell you). So in future you may be better off asking in forum707
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top