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

load directory tree into data repeater

Posted on 2000-03-10
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.
Question by:waldronr
  • 5
  • 3
  • 2

Expert Comment

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

strStartDirectory = "C:\"

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

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

End Sub

Expert Comment

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?

Author Comment

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.
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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!!!

Expert Comment

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...
LVL 70

Expert Comment

by:Éric Moreau
ID: 2614508

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!

Accepted Solution

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

Author Comment

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.

Author Comment

ID: 2615988
Thanks alot, you really helped me get to the solution i needed.

Expert Comment

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

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

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 60
using Access 8 75
Excel VBA, find a string in a column, update a cell 7 86
how to Classify of email (pdf attachments) 7 45
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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