View Full Version : save folder name to table
hi.. I used this module to save the file directory in new created table. This code i got from searching in the google. so the problem is.... how to save the folder name to in that table.
there is a few folder in (CurrentProject.Path & "\Kml Shape File\") :
1. lotname
2. place
3. Hotel
Private Function FilesAndDetails()
On Error GoTo Err_FilesAndDetails
Dim rs As Recordset
Dim vDir As Variant
Dim FilewPath As String
FilewPath = (CurrentProject.Path & "\Kml Shape File\") 'sPath must end with a back slash, sPath = "C:\Windows\"
CurrentDb.Execute "Delete tTempFiles.* from tFiles;"
Set rs = CurrentDb.OpenRecordset("tFiles")
vDir = Dir(FilewPath & "*.*")
Do Until vDir = ""
rs.AddNew
rs!FilePathName = FilewPath & vDir
rs!FilePath = FilewPath
rs!FileFolde = ??????????????
rs!FileName = vDir
rs!ModifiedDate = FileDateTime(FilewPath & vDir)
rs!FileSize = FileLen(FilewPath & vDir)
rs.Update
vDir = Dir
Loop
rs.Close
Set rs = Nothing
DoCmd.Requery
Exit_FilesAndDetails:
Exit Function
Err_FilesAndDetails:
MsgBox Err.Number & " - " & Err.description
Resume Exit_FilesAndDetails
what should i put at ?????????? (red colour) this part in this code.
vbaInet 04-01-2010, 07:28 PM Copying and pasting code into your project without understanding what it does wouldn't help you. This seems to be a simple enough one I think if you really look into it you would understand.
I know you're able ;)
thanks... for reply.
i try to understand this code... but the problem is :
1. my English is not so good as u
2. ms access is not my expertise.... (just as hobby)
anyway... i try my best....
there is a few code I understand... how it's function.
I think ... to solve my problem is ... I should understand this code
vDir = Dir(FilewPath & "*.*")
so can u translate it to simple word.... to make me easily understand it.
what is "." for???
vbaInet 04-01-2010, 08:06 PM Remember when you use LIKE in a query and you put the asterisk (*) to find possible matches. Let's say, a criteria was this:
LIKE *1*Will give results 010, 210 etc as long as there is a one in the middle.
All that line of code is doing is saving the first file name that matches what Dir returns. So FileWPath & "*.*" could be
FileWPath100.pdf
FileWPath_patter.doc
... etc.
Finally, check the help files in the VBA editor for more explanations.
ajetrumpet 04-01-2010, 08:22 PM UMMM...
doesn't the code: currentproject.path give you the ENTIRE address of the file you have open? If it does, I don't think this is possible:FilewPath = (CurrentProject.Path & "\Kml Shape File\")Looks like you're adding another subdirectory AFTER the file name, unless I'm wrong (which don't doubt that I am, because I'm usually unpopular)
vbaInet 04-01-2010, 08:33 PM In actual fact, I think maybe all the OP is trying to do is save those folder names in bold into the table?so the problem is.... how to save the folder name to in that table.
there is a few folder in (CurrentProject.Path & "\Kml Shape File\") :
1. lotname
2. place
3. HotelIf that's the case then a recordset isn't need. Just the FileSystem object.
Yes, Adam you're right in thinking that that line is referring to a sub-directory. I would imagine that path already exists. It may also be that those three folders mentioned above are all under the sub-direcory "Kml Shape File".
ajetrumpet 04-01-2010, 08:41 PM just thought i would point out the unobvious. remember, my opinion is a devalued one, so don't put much faith in it. :rolleyes:
It's still above the dollar though!
vbaInet 04-01-2010, 08:47 PM It's still above the dollar though!Well, you're doing rather well. Looks like one trades in foreign currencies?:D
ajetrumpet 04-01-2010, 08:53 PM Well, you're doing rather well. Looks like one trades in foreign currencies?:Dyeah, my account is listed on the FOREX under InsultsUnlimited :D
I think I'm gonna cut this thread off before we draw anymore attention buddy. See you in the realm of other cyberspace.
Yes, Adam you're right in thinking that that line is referring to a sub-directory. I would imagine that path already exists. It may also be that those three folders mentioned above are all under the sub-direcory "Kml Shape File".
it's true.... i want to put the name of tree sub folder name (place, lotname and hotel) under folder "Kml Shape File" into table automatically as i put filename
How to make this code to show all data including folders not only the file.
vDir = Dir(FilewPath & "*.*") i try change it to this :
vDir = Dir(FilewPath & "**")
still don't work.
ghudson 04-02-2010, 04:35 AM How to make this code to show all data including folders not only the file.
vDir = Dir(FilewPath & "*.*") i try change it to this :
vDir = Dir(FilewPath & "**")
still don't work.
Check out how I do it in my Browse [Find a directory or file] (http://www.access-programmers.co.uk/forums/showthread.php?t=97787) sample.
hi ghudson, I already see it. but for me (as a beginner) it's too complex. ... can u give me any hint..... which part i should concentrate ..... module or form...????
i think in this code:
Public Function BrowseDirectory(szDialogTitle As String) As String
On Error GoTo Err_BrowseDirectory
Dim X As Long, bi As BROWSEINFO, dwIList As Long
Dim szPath As String, wPos As Integer
With bi
.hOwner = hWndAccessApp
.lpszTitle = szDialogTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With
dwIList = SHBrowseForFolder(bi)
szPath = Space$(512)
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
If X Then
wPos = InStr(szPath, Chr(0))
BrowseDirectory = Left$(szPath, wPos - 1)
Else
BrowseDirectory = ""
End If
Exit_BrowseDirectory:
Exit Function
Err_BrowseDirectory:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_BrowseDirectory
End Function
difficult to understand ..... :o:o:o
|