?
Solved

load directory tree into data repeater

Posted on 2000-03-10
10
Medium Priority
?
189 Views
Last Modified: 2013-12-25
this is what i'm trying to accomplish.

i created a custom control to display a folder name and size. then i created a form with a drive list box and a dir list box and a data repeater. I inserted the custom control as the repeated control of the data repeater.

what i need to do is add the subfolder names of the selected folder to the data repeater.
0
Comment
Question by:waldronr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2612307
Something like this should do the trick:

Private Sub Form_Load()
Dim rs As ADODB.Recordset
Dim strFolderName
Dim strStartDirectory

Set rs = New ADODB.Recordset
rs.Fields.Append "FolderName", adBSTR
rs.Open

strStartDirectory = "C:\"

strFolderName = Dir(strStartDirectory, vbDirectory)
Do While strFolderName <> ""
   If strFolderName <> "." And strFolderName <> ".." Then
      If (GetAttr(strStartDirectory & strFolderName) And vbDirectory) = vbDirectory Then
        rs.AddNew
        rs.Fields(0) = strFolderName
        rs.Update
      End If
   End If
   strFolderName = Dir
Loop

Set DataRepeater1.DataSource = rs
DataRepeater1.RepeatedControlName = "RichText.RichTextCtrl"
DataRepeater1.RepeaterBindings.Add "Text", "FolderName"

End Sub
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2612314
I reread your question and now I'm not sure whether my example will actually help you. If it's not what you are trying to achieve, could you please explain more clearly where you want the names of the subfolders with respect to the ocx you already have as your repeated control?
0
 

Author Comment

by:waldronr
ID: 2613741
ok, i have a drvlistbox with a dir list box below it. what i want to happen is when i change either, i want the subfolders of the selected dir to list in a custom control i built inside a data repeater.

your example was lots of help. the code you entered only worked for root directories, but i was able to modify it to work out. thanks.

i thought there was a way to do it with a data environment or something( i swear i heard something about it in one of the MS mastering series courses, but i couldn't find the reference.

if you know what i'm talking about let me know or i could just give you the points now. if you could just let me know if what i'm saying sounds familar or possible. either way i'll give you the points.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2613778
«i thought there was a way to do it with a data environment or something( i swear i heard something about it in one of the MS mastering series courses, but i couldn't find the reference.»

I teach 3 of the VB courses (1303, 1013 and 1016). Yes there is an example of using the DataRepeater in the 1013 course but and it is bounded to the DataEnvironment. But you can't open a folder from the DataEnvironment!!!
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2613904
Emoreau: Thanx for this comment, since I don't have access to MOC material myself.

I'm also quite sure there is no way to tell a data-environment at designtime to hold folders/sub-folders. If you do want to use the data-environment you should add a command at runtime and then bind it to the data-repeater at runtime. This involves even more steps then in my example, so I don't know whether that sounds attractive or not.

Anyway I'm glad that you found the example to be of help...
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2614508
p_biggelaar,

The way you do it (by creating a disconnected recordset) is THE way of doing it if you want to have the result in the data repeater!
0
 
LVL 2

Accepted Solution

by:
p_biggelaar earned 1800 total points
ID: 2615478
Thought so too. I'm quite honored that someone with your status in EE can back my answer ;-)
0
 

Author Comment

by:waldronr
ID: 2615983
it seems to work fine now, i don't want to have to go thru any more trouble than i need to.thanks again, i really appreciate your help.
0
 

Author Comment

by:waldronr
ID: 2615988
Thanks alot, you really helped me get to the solution i needed.
0
 
LVL 2

Expert Comment

by:p_biggelaar
ID: 2616134
Like I said before, I'm glad to be of help
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question