![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
There was a question a while ago about making directories from a table, specifically creating an artistes folder so music albums can be stored by artist. Anyone have a little routine stored away on their compendium of access goodies? I suppose another useful function would be to check if a directory is empty and delete it as well so it cleanses any redundant folders. I could probably adapt a routine I have already for reading a table and use MKDIR to create them, but someone may already have an effective and tight method of doing it ? J |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
There was some useful data in the Stuart McFall pages, didn't realise the ex Rangers man was multi-skilled. Used the routine below to make a start, this works OK, will probably develop a bit further to remove empty directories etc. Private Sub dirprintcombut_Click() On Error GoTo Err_dirprintcombut_Click Dim db As Database Set db = CurrentDb() Dim RS As DAO.Recordset Dim artistname As String Dim Rootfolder As String Dim dirtobecreated As String ' Name of folder where directories are to be created - error if it doesn't exist Rootfolder = "E:\Test\" ' Open each entry in table one at a time - I used folder print to export a table Set RS = db.OpenRecordset("SELECT * FROM ArtisteQuery") Do While Not RS.EOF artistname = RS![Artist] ' Create each prospective foldername dirtobecreated = Rootfolder & artistname ' If the foldername doesn't exist then create it - this will allow mods to list later on If Len(Dir(dirtobecreated, vbDirectory)) = 0 Then MkDir dirtobecreated End If RS.MoveNext Loop RS.Close ' Close recordset on completion Exit_MySub: Set RS = Nothing Set db = Nothing Exit Sub Exit_dirprintcombut_Click: Exit Sub Err_dirprintcombut_Click: MsgBox Err.Description Resume Exit_dirprintcombut_Click End Sub |
#5
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |