Here is the code for my Access 2003 database.
-----------------------------------------------
Option Compare Database
Option Explicit
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
MyStringForm = ""
Dim MyFileName As String
Dim MyFileExt As String
Dim MyString, MyNumber
Dim MyFile, MyFolder, SourceFile, DestinationFile
MyFileName = Forms![Documents]![DocumentID]
MyFileExt = Forms![Documents]![EntryValue]
MyFolder = "//"serverip"/NWSDocuments/" & MyFileName & "." & MyFileExt
MyFile = Dir(MyFolder, vbDirectory)
If MyFile = "" Then
MsgBox "File not found.", vbOKOnly + vbInformation, "No File"
Exit Sub
End If
MyFile = "//"serverip"/NWSDocuments/" & MyFileName & "." & MyFileExt
Close #1
Open MyFile For Input As #1 ' Open file for input.
Do While Not EOF(1) ' Loop until end of file.
MyString = Input(1, #1) ' Get one character.
Debug.Print MyString ' Print data to Debug window.
If MyStringForm = "" Then
MyStringForm = MyString
Else
MyStringForm = MyStringForm & MyString
End If
Loop
Close #1 ' Close file.
Me.Narrative = ConvertWord(MyStringForm)
End Sub
Private Sub Report_Activate()
DoCmd.Maximize
End Sub
Private Sub Report_Close()
DoCmd.Restore
End Sub
Function ConvertWord(RTFString As String)
Dim tempstring As String, RTFlength As Long, RTFposition As Long, bPosition As Long
RTFposition = InStr(1, RTFString, "\fs24")
RTFlength = Len(RTFString)
If RTFposition > 0 Then
tempstring = Right(RTFString, RTFlength - RTFposition - 4)
Else
tempstring = RTFString
End If
RTFposition = InStr(1, tempstring, "\fs29")
RTFlength = Len(tempstring)
If RTFposition > 0 Then
tempstring = Right(tempstring, RTFlength - RTFposition - 4)
Else
tempstring = tempstring
End If
bPosition = InStr(1, tempstring, "\par")
Do While Not bPosition = 0
Mid(tempstring, bPosition, 4) = " "
bPosition = InStr(1, tempstring, "\par")
Loop
bPosition = InStr(1, tempstring, "\cf0")
Do While Not bPosition = 0
Mid(tempstring, bPosition, 4) = " "
bPosition = InStr(1, tempstring, "\cf0")
Loop
bPosition = InStr(1, tempstring, "}")
Do While Not bPosition = 0
Mid(tempstring, bPosition, 1) = " "
bPosition = InStr(1, tempstring, "}")
Loop
bPosition = InStr(1, tempstring, "\line")
Do While Not bPosition = 0
Mid(tempstring, bPosition, 5) = " "
bPosition = InStr(1, tempstring, "\line")
Loop
ConvertWord = tempstring
End Function
--------------------------------------------
I have bolded the problem code. This code is pointing to a folder on a server. When the database calls for a certain DocumentID, it searches this folder. Now, the program that created these logs creates subfolders based on the documentid and the database can no longer pull files. I want to do one of two things.
Either:
Recode this part to automatically look in all subfolders for a file
OR
Recode this to search the current folder and if it's no there then look in the subfolder based on the documentID.
The subfolder structure is to 1. Create a subfolder based on the first 4 characters of the filename 2. Create a second subfolder based on the next two characters 3. deposit files
EX.
filename = xxxxyy22
goes to
\\xxxx\yy\xxxxyy22.doc
Thank you all so much