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

Can anyone tell me how I can alter

Status
Not open for further replies.

LadyDev

Programmer
Jan 29, 2003
86
US
Can anyone tell me how I can alter the attached Explore97.mdb ( to display on certain directory on a PC. Presently it displays every dir on the system. I have files located on v:\web\tools\files. If I only want to display those files located under 'tools' in the explorer - what do I alter first?

And is it any way to make it look more like a 'treeview' in that when you open the main file on a 'treeview' it stays open and displays the files. On the explorer if you double-click the main folder disappears and you a left with just the files. It's kind of hard to remember which folder you opened.
 
hey that's cool.

I think the copyright on that code says you aren't supposed to edit it. I don't know how that works, but I don't think anyone here wants to help you violate it. I do have a helpful solution though.

I have something similiar. It's a bit simpler, it doesnt' pull all of the directories. It does pull file lists from whatever path you want, and you can set a default path. You can also use the list as a hyperlink to open the file. I can email it to you. It would do what you are asking. Or I can post the code and you can set it up. That way other people may use it.



Mark P.

Bleh
 
Hey thanks Mark. Now that's COOL!! Whichever way is more convenient for you. My email address is ashe927@aol.com.

By the way, I think you are wrong about the copyright. According to the web site, anyone can use the programs as long as you don't try to SELL them as you own. If you are smart enough (which I am not) to change it to fit your needs--that's fine. You just can't profit from it -- which is also cool!

Thanks, I'd like to look at your program.
 
Well, it said you aren't allowed to alter it. However, i don't see how you could learn vba and not alter it.

The other thing is... for some reason, probably cause Dev Ashish is an access genius, the on from the site works a bit faster then mine when looking up directories with a lot of files, like 100 or more.

I use mine a lot though, we use it to look up files associated with clients, so after we create a folder for a client the path for the client can be looked up as the default path, it then displays all the files for that client.

Anyways,

This is how it works:

on a form i have an unbound listbox(lstFolderContents) and an undbound textbox(txtFolderLocation). I have three buttons: btnDocuments, btnImages, btnAllFiles; those buttons set what files will be displayed in the list box. I also have a transparent button to use as a hyperlink: btnLink.

For your specific solution.... You can either set the default of the txtbox through code: like v:\web\tools\files, or make it bound as a dlookup or something to a table or maybe something else.


If anyone has any suggestions on how to improve this i would be greatful. Also, I used a module written by terry craft to browse folders, but it doesn't work in the form like Dev Ashish's does. I'll have to look at his. Currently the listbox also doesn't show the subfolders. I was looking in how to do that, i just wrote this module on last week, so i'm sure there should be some improvement, but so far it's been great.
Then you can put this in the forms module:

Function ClearList()

lstFolderContents.RowSource = ""
lstFolderContents.RowSourceType = "Value List"

End Function


Function fncGetFiles(intSelect As Integer)
Dim MyFolder$, myfile
Dim intFilesize As Double
Dim stFS As String
lstFolderContents.ColumnHeads = True

' list headers
lstFolderContents.RowSource = "File Name; Size; Date Created;"

' some of the folder selections are typed in with a \ others aren't. this makes sure there is a \ at the end of of the string
strName = Me!txtFolderLocation & "\"
If right(strName, 2) = "\\" Then
strName = Me!txtFolderLocation
End If

lstFolderContents.RowSourceType = "value list"
MyFolder = strName
myfile = Dir(MyFolder)

DoCmd.Hourglass True
While myfile <> &quot;&quot;
' this decides whether the file is smaller or larger then a mb for display in the second column


If FileLen(strName & myfile) / 1000 < 1 Then
intFilesize = Round((FileLen(strName & myfile) / 1), 0)
stFS = intFilesize & &quot; bytes&quot;
Else
If FileLen(strName & myfile) / 1000 > 2000 Then
intFilesize = Round((FileLen(strName & myfile) / 1000000), 2)
stFS = intFilesize & &quot; mb&quot;
Else
If FileLen(strName & myfile) / 1000 < 2000 Then

intFilesize = Round((FileLen(strName & myfile) / 1000), 0)
stFS = intFilesize & &quot; kb&quot;


End If
End If
End If
'check to see what button was pushed. all files would be selection one, it doesn't need a filter.
If intSelect = 2 Then
If right(myfile, 4) = &quot;.gif&quot; Or right(myfile, 4) = &quot;.jpg&quot; Or right(myfile, 4) = &quot;.png&quot; Or right(myfile, 4) = &quot;.bmp&quot; _
Or right(myfile, 4) = &quot;.tif&quot; Or right(myfile, 5) = &quot;.jpeg&quot; Then
Else
' if the item is not in the filtered group, the are send down to move on to the next file.
GoTo WendOut:
End If
Else
If intSelect = 3 Then
If right(myfile, 4) = &quot;.xls&quot; Or right(myfile, 4) = &quot;.doc&quot; Or right(myfile, 4) = &quot;.txt&quot; Or right(myfile, 4) = &quot;.rtf&quot; _
Or right(myfile, 4) = &quot;.htm&quot; Or right(myfile, 5) = &quot;.html&quot; Or right(myfile, 4) = &quot;.xml&quot; Then
Else
' if the item is not in the filtered group, the are send down to move on to the next file.
GoTo WendOut:
End If

End If
End If
' once the files have been filtered then come down to these lines to fill the columns
lstFolderContents.RowSource = lstFolderContents.RowSource & _
myfile & &quot;;&quot; & _
stFS & &quot;; &quot; & _
Format(FileDateTime(strName & myfile), &quot;Short Date&quot;) & &quot;; &quot;

WendOut:

myfile = Dir

Wend
DoCmd.Hourglass False



finderror:
Debug.Print lstFolderContents.RowSource
Debug.Print Len(lstFolderContents.RowSource)
End Function


The call this for the buttons

Private Sub btnAllFiles_Click()
ClearList
fncGetFiles 1
End Sub

Private Sub btnImages_Click()
ClearList
fncGetFiles 2
End Sub

Private Sub btnDocuments_Click()
fncGetFiles 3
ClearList
End Sub

' and this for the onclick event of the listbox.
Private Sub lstFolderContents_Click()

strName = Me!txtFolderLocation & &quot;\&quot;
If right(strName, 2) = &quot;\\&quot; Then
strName = Me!txtFolderLocation
End If

strLink = strName & lstFolderContents

Set ctl = Me!btnLink
With ctl
.Visible = False
.HyperlinkAddress = strLink
.Hyperlink.Follow
End With
End Sub





Mark P.

Bleh
 
Shoot, i forgot one thing. The round function is only avalible in XP, i'm not sure it might be avalible in 2000. So you may have to cut out the size display part:

If FileLen(strName & myfile) / 1000 < 1 Then
intFilesize = Round((FileLen(strName & myfile) / 1), 0)
stFS = intFilesize & &quot; bytes&quot;
Else
If FileLen(strName & myfile) / 1000 > 2000 Then
intFilesize = Round((FileLen(strName & myfile) / 1000000), 2)
stFS = intFilesize & &quot; mb&quot;
Else
If FileLen(strName & myfile) / 1000 < 2000 Then

intFilesize = Round((FileLen(strName & myfile) / 1000), 0)
stFS = intFilesize & &quot; kb&quot;


...and then not try to populate that column.

Mark P.

Bleh
 
Or, you can do this...just to show you how it would work

Put this on the on open event of the explorer97.mdb

lblPath = &quot;v:\web\tools\files&quot;
If mstPath = vbNullString Then
mstFilePath = &quot;v:\web\tools\files&quot;
Else
mstFilePath = &quot;v:\web\tools\files&quot;
End If
Me!lbxFiles.Requery
DoCmd.Hourglass False
mboolClick = True: mboolUp = False
DoCmd.Hourglass True
Me!lbxFiles.Requery
DoCmd.Hourglass False

Mark P.

Bleh
 
oops. make that: lblPath.caption = &quot;v:\web\tools\files&quot;


Mark P.

Bleh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top