Solved

load directory tree into data repeater

Posted on 2000-03-10
10
183 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
«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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
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 450 total points
Comment Utility
Thought so too. I'm quite honored that someone with your status in EE can back my answer ;-)
0
 

Author Comment

by:waldronr
Comment Utility
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
Comment Utility
Thanks alot, you really helped me get to the solution i needed.
0
 
LVL 2

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now