ChronicFear
Registered User.
- Local time
- Today, 00:37
- Joined
- Oct 18, 2007
- Messages
- 66
Hello,
I downloaded Ghudson's file here in order to allow my users to view documents relevant to the record they are viewing in the database.
I've made some slight modifications so that the code pulls all the file links from the directory into a table. The code then scans the entire title to grab a unique ID number that corresponds with the record the user is viewing in the database. A query then limits the file links shown to those that correspond with the record, and the user views this in a form.
This works fine in the demo that I downloaded from Ghudson (I imported some of the other files from my db into his for testing). My problem occurs when I try to import the modified table and form from Ghudson into my db. I've made sure that everything is identical between the two, but for some reason it only works in one. In my db it says "13 - Type mismatch error".
I appreciate your help.
Thanks,
CF
My modifications:
I downloaded Ghudson's file here in order to allow my users to view documents relevant to the record they are viewing in the database.
I've made some slight modifications so that the code pulls all the file links from the directory into a table. The code then scans the entire title to grab a unique ID number that corresponds with the record the user is viewing in the database. A query then limits the file links shown to those that correspond with the record, and the user views this in a form.
This works fine in the demo that I downloaded from Ghudson (I imported some of the other files from my db into his for testing). My problem occurs when I try to import the modified table and form from Ghudson into my db. I've made sure that everything is identical between the two, but for some reason it only works in one. In my db it says "13 - Type mismatch error".
I appreciate your help.
Thanks,
CF
My modifications:
Code:
Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
DoCmd.Restore
Call FilesAndDetails
Me.Caption = "Double click on a file to view it."
Exit_Form_Open:
Exit Sub
Err_Form_Open:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Form_Open
End Sub
Public Function FilesAndDetails()
On Error GoTo Err_FilesAndDetails
Dim rs As Recordset
Dim vDir As Variant
Dim sTransID As Variant
Dim sTransID2 As Variant
Const sPath = "\\server\file\file2\file3\" '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)
sTransID = ParseWord(vDir, -1)
sTransID2 = ParseWord(sTransID, -2, ".")
If IsNumeric(sTransID2) Then
rs!TransactionID = sTransID2
End If
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 Function
Private Sub tbFileName_DblClick(Cancel As Integer)
On Error GoTo Err_tbFileName_DblClick
OpenFile tbFilePathName
Exit_tbFileName_DblClick:
Exit Sub
Err_tbFileName_DblClick:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_tbFileName_DblClick
End Sub