Need some help... I'm trying to automate the process of importing files into a temporary table called "tblTemp" with two fields, PurchaseID & ApprovalDocument (ole object). The document title is the same as the purchaseID number. here's what i've got so far.


'------------------------------------------------------------------------------
Function GetMessages(sPath As String)

On Error GoTo ErrorHandler

Dim sFile As String
Dim db As Database, rs As Recordset

sFile = Dir(sPath & "\*.msg")
Set db = CurrentDb
Set rs = db.OpenRecordset("tblTemp", dbOpenDynaset)
On Error Resume Next
Do Until sFile = ""
rs.AddNew
rs!PurchaseID = Left(sFile, Len(sFile) - 4)
rs!ApprovalDocumentFile = sFile
rs.Update
sFile = Dir
Loop
rs.Close
Set rs = Nothing
Set db = Nothing

Exit Function

ErrorHandler:
MsgBox Err.Description

End Function
'--------------------------------------------------------------------------