Solved

load directory tree into data repeater

Posted on 2000-03-10
10
184 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
 
LVL 69

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 69

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…

863 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

21 Experts available now in Live!

Get 1:1 Help Now