Tweaking gHudson's browse database

NascarBaritone

Registered User.
Local time
Today, 15:48
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?

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
 
This gave me a message box with the name of the first record in the database. However, my subform is not visible when my database loads (on purpose). When I click the tab that gives me the subform, the directory is blank meaning it isn't pointing to the variable location.
 
Not exactly. As best I can tell, the correct file information is being loaded into the tFiles table, but is not showing up in the subform. And nothing happens when I try and switch records.

I know the paths won't work for you, but see if you can make sense of the database.
 

Attachments

Users who are viewing this thread

Back
Top Bottom