Solved Open a folder based on record number (1 Viewer)

Mcgregorbart

New member
Local time
Today, 18:47
Joined
Jul 30, 2010
Messages
11
Help if possible please probably will seem basic to most.
I have a form with a command button programmed to open a folder on my network. this folder contains a folder for each record where I store files relating to a given record. This button works fine opens explorer and displays all my sub folders. What I would like it to do is open the folder that pertains to the record that I am viewing. I want it to pick up the NC Number field which is the unique record for each folder also. VBA code I have currently is

Private Sub Command12478_Click()
On Error GoTo Err_cmdExplore_Click

Dim stAppName As String

stAppName = "C:\Windows\explorer.exe F:\Rec Work\NON CONFORMANCE ATTACHMENTS"
Call Shell(stAppName, 1)

Exit_cmdExplore_Click:
Exit Sub

Err_cmdExplore_Click:
MsgBox Err.Description
Resume Exit_cmdExplore_Click

End Sub

Any help would be appreciated tyia
 

Attachments

  • Capture.PNG
    Capture.PNG
    56.4 KB · Views: 137

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,229
So you would append the NCNUmber control value to the existing string.
Debug.Print it before you try and use it. That way you will see if it is correct or not.

Likely all you need is
Code:
stAppName = "C:\Windows\explorer.exe F:\Rec Work\NON CONFORMANCE ATTACHMENTS\" & Me.NCNumber
 

Isaac

Lifelong Learner
Local time
Today, 10:47
Joined
Mar 14, 2017
Messages
8,774
So you would append the NCNUmber control value to the existing string.
Debug.Print it before you try and use it. That way you will see if it is correct or not.

Likely all you need is
Code:
stAppName = "C:\Windows\explorer.exe F:\Rec Work\NON CONFORMANCE ATTACHMENTS\" & Me.NCNumber
I am thinking possibly some more quotes due to the space in folder path name...maybe?
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,229
I am thinking possibly some more quotes due to the space in folder path name...maybe?
Well to me, a number is a number?
Then again that is just me? :(
 

Isaac

Lifelong Learner
Local time
Today, 10:47
Joined
Mar 14, 2017
Messages
8,774
Well to me, a number is a number?
Then again that is just me? :(
I was referring to the spaces in this path
\Rec Work\NON CONFORMANCE ATTACHMENTS
 

Gasman

Enthusiastic Amateur
Local time
Today, 18:47
Joined
Sep 21, 2011
Messages
14,229
Well the O/P said that part was working, so I thought they just need to append the NCnumber
 

Mcgregorbart

New member
Local time
Today, 18:47
Joined
Jul 30, 2010
Messages
11
So you would append the NCNUmber control value to the existing string.
Debug.Print it before you try and use it. That way you will see if it is correct or not.

Likely all you need is
Code:
stAppName = "C:\Windows\explorer.exe F:\Rec Work\NON CONFORMANCE ATTACHMENTS\" & Me.NCNumber
Thank you just had to add underscore NC_Number (forgot about space.) works like a charm cheers
 

Users who are viewing this thread

Top Bottom