Shell function not working for one user (1 Viewer)

Alc

Registered User.
Local time
Today, 04:01
Joined
Mar 23, 2007
Messages
2,407
The following function is in the front end of a database used by four people plus myself. We all share the same front end, so references, etc. are unchanged.

For all bar one of us, it works fine:
1. It checks if a file for a particular VIN is in a folder for a particular Dealer, which is in either the 'HDS' or 'iHDS" folder.
2. If it is present, the file is opened.
3. If it isn't present, a message is displayed to that effect.
Code:
Private Sub btnHDS_Click()
    Dim strFoldername As String
    Dim strVIN As String
    Dim strDealerCode As String
    
    strDealerCode = Me!DEALER_CODE
    strVIN = Nz(Me.VIN, "")
    If strVIN = "" Then
        strMsg = "No VIN was selected"
        strTitle = "Process cancelled"
        strResponse = MsgBox(strMsg, vbOKOnly, strTitle)
        Exit Sub
    End If
    
    strFoldername = "R:\HDS" & "\" & strDealerCode & "\" & strVIN
    If FolderExists(strFoldername) Then
        Shell "C:\WINDOWS\explorer.exe """ & strFoldername & "", vbNormalFocus
        Exit Sub
    End If
    strFoldername = ""
    
    strFoldername = "R:\iHDS" & "\" & strDealerCode & "\" & strVIN
    If FolderExists(strFoldername) Then
        Shell "C:\WINDOWS\explorer.exe """ & strFoldername & "", vbNormalFocus
        Exit Sub
    End If
    
    strMsg = "Sub folder '" & VIN & "' not found in either HDS or iHDS"
    strTitle = "Process cancelled"
    strResponse = MsgBox(strMsg, vbOKOnly, strTitle)
End Sub

For this one user, there is no error message but the final 'Sub folder not found' message is always displayed, regardless of whether or not a file is present.
So far, I've tried the following:
1. Confirmed that the user has access to the folder/files in question.
2. Added message boxes at each stage of the process, to verify that all strings hold the correct values
3. Restarted the database
4. Restarted his PC
5. Tested that this problem occurs when he's the only person logged in as well as when there are multiple users logged in

This is my first time using 'Shell'.
Does one of those people with more knowledge and experience than myself know if something needs to be present on a person's PC before that function will work?
Is there anything that stops it working?
 

Ranman256

Well-known member
Local time
Today, 04:01
Joined
Apr 9, 2015
Messages
4,339
Does the exploerer.exe exist in that exact folder?
if not, it will fail.

also Dont use Letter drives on networks.
Always use DNC names, the full path": \\server\folder\...
 

Alc

Registered User.
Local time
Today, 04:01
Joined
Mar 23, 2007
Messages
2,407
Explorer was in the same folder.

Your 'also' was the problem. It hadn't come up before, since most PCs here are set up with the same image on each, resulting in each having the same drive letters. This user has a very old computer and it predated the drive being called 'R'. As soon as I edited
Code:
strFoldername = "R:\iHDS" & "\" & strDealerCode & "\" & strVIN
such that it contained the full path, it worked fine for him and on the other four PCs.

I always used to refer to drives that way, but I got lazy since coming here. Lesson learned.

Thanks so much, you saved me a lot of hassle.
 

Users who are viewing this thread

Top Bottom