I would like to insert a filename from a specific directory into a record in a table. I only want to story the filename (e.g. dark.ini) and not the whole path. is there anyway to do it within access97? thanks.
guess i didn't explain it very werll
I want to insert a cd into the cd drive and then by pussing abutton on a form insert the filenames into a table. I hope it can be realised thnx anyway
This code captures the File Names from the "E:\" drive and stores them into a table named "tblCdFileNames" in the Field "CdFileName"
This does not open additional folders in the directory, only captures the File Names.
Private Sub Command0_Click()
On Error GoTo errHandler
Dim strFile As String
Dim db As DAO.database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("tblCdFileNames"
strFile = Dir("E:\"
Do While Len(strFile) > 0
With rst
.AddNew
rst!CdFileName = strFile
.Update
End With
strFile = Dir
Loop
MsgBox "Done"
Exit Sub
errExit:
rst.Close
Set rst = Nothing
Set db = Nothing
errHandler:
MsgBox Err.Number & " : " & Err.Description, vbCritical, "Unexpected Error"
GoTo errExit
End Sub
this code stripes the folder info. off the whole path so you end up with just the file name.
----------------------
'get just the path from the Acad fullname variable above
For A = 1 To Len(FullPathandDWG)
FindSlash = InStr(A, FullPathandDWG, "\"
If FindSlash = 0 Then Exit For
A = FindSlash
FindSlash1 = FindSlash
Next
JustPath = Left(FullPathandDWG, FindSlash1)
Dwgnum1 = Right(FullPathandDWG, Len(FullPathandDWG) - Len(JustPath))
'trim Off the .dwg on the end
Dwgnum = Left(Dwgnum1, Len(Dwgnum1) - 4)
------------
this is for autoCAD drawings but it will work for any files
DougP, MCP
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.