Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing the filename in a record

Status
Not open for further replies.

Venturi

Programmer
May 22, 2001
14
NL
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

PaulF
 
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

Visit my WEB site to see how Bar-codes can help you be more productive
 
Thanks guys!!!!!
This really helped me a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top