NascarBaritone
Registered User.
- Local time
- Today, 03:56
- Joined
- Sep 23, 2008
- Messages
- 75
I am using the Browse... sample database posted by gHudson and and stuck in one place.
I have the form with the file directory as a subform to my main form. I am not getting any errors, but the files don't update based on the variable path I have spelled out. Any suggestions based on my code?
I have the form with the file directory as a subform to my main form. I am not getting any errors, but the files don't update based on the variable path I have spelled out. Any suggestions based on my code?
Code:
Private Function FilesAndDetails()
On Error GoTo Err_FilesAndDetails
Dim rs As DAO.Recordset
Dim vDir As Variant
Dim Y As String
Dim vardoc As String
vardoc = Forms![Reps]!LastName.Value & ", " & Forms![Reps]!FirstName.Value
Y = Left(Forms![Reps]!LastName.Value, 1)
If Y >= "A" And Y <= "G" Then
vardoc = "K:\Corporate Compliance\Rep Appointments\Sent Appointment Applications\Last Name A-G\" & vardoc
ElseIf Y >= "H" And Y <= "N" Then
vardoc = "K:\Corporate Compliance\Rep Appointments\Sent Appointment Applications\Last Name H-N\" & vardoc
ElseIf Y >= "O" And Y <= "Z" Then
vardoc = "K:\Corporate Compliance\Rep Appointments\Sent Appointment Applications\Last Name O-Z\" & vardoc
Const sPath = "vardoc\" 'sPath must end with a back slash, sPath = "C:\Windows\"
CurrentDb.Execute "Delete tTempFiles.* from tFiles;"
Set rs = CurrentDb.OpenRecordset("tFiles")
vDir = Dir(sPath & "*.*")
Do Until vDir = ""
rs.AddNew
rs!FilePathName = sPath & vDir
rs!FilePath = sPath
rs!FileName = vDir
rs!ModifiedDate = FileDateTime(sPath & vDir)
rs!FileSize = FileLen(sPath & 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
End If
End Function