R
Raymond To
Hello.
I am try to write a code for the list box to
display files on the current directory and
files on all sub-directories.
Can anyone help me please?
Here are the code I wrote for display *JPG file from
current directory. And now I want to do something
which able to display all sub-directory.
Private Sub cmdDISPLAY_JPG_Click()
Dim MyPath, MyName
Dim sLIST As String
Dim sSQL As String
Dim rsDISPLAY
MyPath = Nz(Me.txtDIR, "") ' Set the path.
MyName = Dir(MyPath, vbDirectory)
' Retrieve the first entry.
sSQL = "DELETE * FROM tbl_PICTURE"
dbPICTURE.Execute sSQL, dbSeeChanges
Do While MyName <> "" ' Start the loop.
If UCase(Right(MyName, 4)) = ".JPG" Then
sSQL = "INSERT INTO tbl_PICTURE"
sSQL = sSQL & " (P_DIR, P_FILE"
sSQL = sSQL & " ) VALUES ("
sSQL = sSQL & Chr$(34) & Nz(MyPath, "")
& Chr$(34) & ", "
sSQL = sSQL & Chr$(34) & Nz(MyName, "")
& Chr$(34)
sSQL = sSQL & " )"
dbPICTURE.Execute sSQL, dbSeeChanges
End If
MyName = Dir ' Get next entry.
Loop
sLIST = "SELECT P_FILE, P_DIR FROM tbl_PICTURE"
Me.lstFILES.RowSource = sLIST
Me.lstFILES.Requery
End Sub
I am try to write a code for the list box to
display files on the current directory and
files on all sub-directories.
Can anyone help me please?
Here are the code I wrote for display *JPG file from
current directory. And now I want to do something
which able to display all sub-directory.
Private Sub cmdDISPLAY_JPG_Click()
Dim MyPath, MyName
Dim sLIST As String
Dim sSQL As String
Dim rsDISPLAY
MyPath = Nz(Me.txtDIR, "") ' Set the path.
MyName = Dir(MyPath, vbDirectory)
' Retrieve the first entry.
sSQL = "DELETE * FROM tbl_PICTURE"
dbPICTURE.Execute sSQL, dbSeeChanges
Do While MyName <> "" ' Start the loop.
If UCase(Right(MyName, 4)) = ".JPG" Then
sSQL = "INSERT INTO tbl_PICTURE"
sSQL = sSQL & " (P_DIR, P_FILE"
sSQL = sSQL & " ) VALUES ("
sSQL = sSQL & Chr$(34) & Nz(MyPath, "")
& Chr$(34) & ", "
sSQL = sSQL & Chr$(34) & Nz(MyName, "")
& Chr$(34)
sSQL = sSQL & " )"
dbPICTURE.Execute sSQL, dbSeeChanges
End If
MyName = Dir ' Get next entry.
Loop
sLIST = "SELECT P_FILE, P_DIR FROM tbl_PICTURE"
Me.lstFILES.RowSource = sLIST
Me.lstFILES.Requery
End Sub