loadfromfile - HELP!

jamesdpmullan

Registered User.
Local time
Today, 13:18
Joined
Oct 21, 2013
Messages
24
Hi,

I am trying to allow the user to click a command button which will then attach all documents held within a specific folder to an attachment field in the database. I have managed to write the code to a specific file within a specific folder, however, i need to be able to attach all files without knowing the file name.

I have the following code but doesn't do anything. Where am i going wrong?? - any help greatly appreciated...

Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset2
Dim rsA As DAO.Recordset2
Dim fld As DAO.Field2
Dim strFile As String

    Set dbs = CurrentDb
    Set rst = dbs.OpenRecordset("as9102_release")
    Set fld = rst("AS9102LabAttachment")

    Do While Not rst.EOF
    
        Set rsA = fld.Value
        
   


strPath = ("\\tam-fs-01\invotec.databases$\Approval Documents\Laboratory Reports\Telford\" & Replace(Me.CustomerCode, "/", "-") & "\" & Me.FormRelWorksOrderNumber)

strFile = (strPath & "\*.*")

        rst.Edit
        Do While Len(strFile) > 0
        rsA.AddNew
        rsA("FileData").LoadFromFile strFile
        rsA.Update
    
        'LoadAttachments = LoadAttachments + 1
'        End If
        strFile = Dir
  
        Loop
        
        rsA.Close
        
        
    
        
        rst.Update
        rst.MoveNext
    
    Loop
    
    rst.Close
    dbs.Close
    
    Set fld = Nothing
    Set rsA = Nothing
    Set rst = Nothing
    Set dbs = Nothing
 
OK - now i get not a valid file name error.

I kind of expected that but the "\*.*" should find everything??

run time error 3055 not a valid file name
 

Users who are viewing this thread

Back
Top Bottom