?
Solved

load directory tree into data repeater

Posted on 2000-03-10
10
Medium Priority
?
191 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
  • 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
Technology Partners: 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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

840 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