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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Windows Explorer in a specified folder 1

Status
Not open for further replies.

LimitedTech

Technical User
Aug 4, 2008
71
US
I have read several threads that look way over complicated for what I am attempting to do.
I would like to store images (pdfs mostly) in a folder that will have a name that corresponds to a text field in my database.

I want to place a button on the form that will open Windows Explorer in the specified folder based on the value in a text box.

I can use "Explorer /e,C:\Windows" (in the OnClick event) to open explorer but it obviously doesn't allow me to make it dynamic depending on the value in the text box.

The path to the folders will be f:\mydocuments\Archive\XXXXX
where XXXXX will be the folder name from the record. (text but actually a 5 digit number)

The control that will be used is called OrderNumber

Access 2000
Windows XP

I would also be interested to know if a way exists to automatically create the folder when the record is made, if it doesn't already exist.

Thanks!



 
use "Explorer /e,f:\mydocuments\Archive\" & Me!OrderNumber

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

I have similar based on a Job number field name JnAlpha
which can be a number or text.
It will open the Folder with the name of the number in the Job number field

Hope this Helps

This is my
Private Sub Command113_Click()
On Error GoTo ErrCommonDialog1
GetFileInformation (Find_File("Z:\QUOTES & JOBS\JOBS\" & [JnAlpha]))
MsgBox glPath 'Displays the path of the selected file
MsgBox glFileName 'Displays the nameof the selected file
ErrCommonDialog1:

End Sub
 
Sorry i just read your second question.

This works for me, a bit more complicated as i create a Job number folder and severl sub folders with in that.

Hope this helps


Private Sub Command121_Click()
Dim strPath As String


strPath = "C:\QUOTES & JOBS\JOBS\" & [JnAlpha]
If Dir(strPath, vbDirectory) = "" Then


MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha]
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Comercial"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Corro"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Drawings"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Estimate"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Photo"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Program"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "QA-QC"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "OHS"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Submission"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Corro" & "\" & "In"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Corro" & "\" & "Out"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Submission" & "\" & "Original"
MkDir "z:\QUOTES & JOBS\JOBS\" & [JnAlpha] & "\" & "Submission" & "\" & "Revised"
End If
 

Ooops

"C;\ should be

strPath = "Z:\QUOTES & JOBS\JOBS\" & [JnAlpha]
If Dir(strPath, vbDirectory) = "" Then
to match the rest of the script
being that Z is a mapped drive on the server.
but you can use whatever drive letter you wish as long as it is constant.

 
Thanks,
I will give these a shot over the weekend but they look like exactly what I was shooting for.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top