Folders from table error 75 (there are folder/s)

crovella

New member
Local time
Today, 22:10
Joined
Sep 26, 2014
Messages
9
I would like to make Folders from table, but when there is a folder the sub go to error 75
Is there resolution? :banghead:

Thank you very much

Private Sub Comando14_Click()
On Error GoTo ErrComando14_Click
Dim strSQL As String
Dim strPath As String
Dim rst As DAO.Recordset
strSQL = "SELECT cartella2 FROM tblDirectory WHERE ((cartella2) Is Not Null);"
strPath = "D:\Esempio\"
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF
MkDir strPath & rst("Cartella2")
rst.MoveNext
Loop
MsgBox "Operazione conclusa"
End If
ErrComando14_Click: MsgBox Err.Description & " - " & Err.Number
End Sub
 
Cleanest option
Check with a DIR before creating it if the folder already exists

Dirty option
Add an "On error goto next" before your do while, this will make your code ignore errors and run to completion, either the folder exists or not... This may cause issues down the line.
 
You need to check that the folder doesn't already exist before making it. Lookup the Dir() function.


Doh - beaten to it by the postie :)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom