I am tied up at the moment and I can see I need to READ this. If no on else comes along... please be patient while I do my day job.![]()
No worries at all... thank you for your time.
I am tied up at the moment and I can see I need to READ this. If no on else comes along... please be patient while I do my day job.![]()
Private Sub cmdBrowseToFile_Click()
    Dim fDialog    As Object
    Dim varFile As Variant
    Dim strPath As String
    Dim partNum As String
 
   ' Set up the File Dialog.
    Set fDialog = Application.FileDialog(1)
 
    With fDialog
      'Set the title of the dialog box. '
        .Title = "Select the File..."
        .InitialFileName = "C:\"
 
      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
        If .Show = True Then
                varFile = .SelectedItems.Item(1)
                Me.txtPath = varFile
                Me.txtDescription = GetFilenameFromPath(Me.txtPath)
                'Me.txtTimestamp = FileDateTime(Me.txtPath)
        Else
                MsgBox "You clicked Cancel in the file dialog box.", vbOKOnly, "Select a File"
        End If
   End With
   
        strPath = "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_visualinspectioninput!PONumber
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
        strPath = "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_visualinspectioninput!PONumber & "\" & "Visual"
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
        partNum = DLookup("PartNumber", "tbl_parts", "ID = " & Forms!frm_visualinspectioninput!PartNumber)
        strPath = "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_visualinspectioninput!PONumber & "\" & "Visual" & "\" & partNum
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
   
   Call CopyFile(Me.txtPath, "C:\adBEs\Links\" & GetFilenameFromPath(Me.txtPath))
   
End Sub
Function GetFilenameFromPath(ByVal strPath As String) As String
' Returns the rightmost characters of a string upto but not including the rightmost '\'
' e.g. 'c:\winnt\win.ini' returns 'win.ini'
 
    If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
        GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1
    End If
End Function
	Call CopyFile(Me.txtPath, "C:\adBEs\Links\" & GetFilenameFromPath(Me.txtPath))
	Call CopyFile("Files Existing Location", "Files New Location"))
	Looks like you are moving right along! Good to hear.
The CopyFile() copies from the existing location, Me.txtPath, to the new location, C:\adBEs\Link\..., so you need to...
Code:Call CopyFile("Files Existing Location", "Files New Location"))
That said, this code was not designed to grab more than one file at a time. You would need a loop for that.
Call CopyFile(Me.txtPath,
	"C:\adBEs\links\"
	& GetFilenameFromPath(Me.txtPath))
	         strPath = "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_visualinspectioninput!PONumber
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
	        strPath = "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_visualinspectioninput!PONumber & "\" & "Visual"
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
	        partNum = DLookup("PartNumber", "tbl_parts", "ID = " & Forms!frm_visualinspectioninput!PartNumber)
        strPath = "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_visualinspectioninput!PONumber & "\" & "Visual" & "\" & partNum
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
	Call CopyFile(Me.txtPath, strPath & GetFilenameFromPath(Me.txtPath))
	Call CopyFile(Me.txtPath, "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_labtestinput!PONumber & "\" & "Visual" & "\" & partNum", & GetFilenameFromPath(Me.txtPath))
	So... I've got that to work (party!!)
but... how do I "start using" the exported file instead??
Private Sub cmdLabAttachments_Click()
    DoCmd.OpenForm "frm_labattachments", , , , , acDialog
End Sub
	Option Compare Database
Option Explicit
Dim RecordID As Integer
Private Sub cmdBrowseToFile_Click()
    Dim fDialog As Object
    Dim varFile As Variant
    Dim savePath As String
    
 
   ' Set up the File Dialog.
    Set fDialog = Application.FileDialog(1)
 
    With fDialog
      'Set the title of the dialog box. '
        .Title = "Select the File..."
 
      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
        If .Show = True Then
            For Each varFile In .SelectedItems
                savePath = GetDirectory() & "\" & GetFilenameFromPath(varFile)
                lstFiles.AddItem 0 & ";" & RecordID & ";" & varFile & ";" & savePath & ";" & GetFilenameFromPath(varFile)
            Next
        Else
            MsgBox "You clicked Cancel in the file dialog box.", vbOKOnly, "Select a File"
            Exit Sub
        End If
   End With
End Sub
Function GetFilenameFromPath(ByVal strPath As String) As String
' Returns the rightmost characters of a string upto but not including the rightmost '\'
' e.g. 'c:\winnt\win.ini' returns 'win.ini'
 
    If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
        GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
    End If
End Function
Function GetDirectory() As String
    Dim strPath As String
    Dim partNum As String
    strPath = "\\aa.com\afi-dfs\arcadia\Dept\International\Engineering - JA\QC Lab\Electrical Audit Database BE\Attachments\" & Forms!frm_home.Lab_Test_Input_Form.Form.PONumber
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
        strPath = strPath & "\" & "Lab"
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
        partNum = DLookup("PartNumber", "tbl_parts", "ID = " & Forms!frm_home.Lab_Test_Input_Form.Form.PartNumber)
        strPath = strPath & "\" & partNum
    If Len(Dir(strPath, vbDirectory)) = 0 Then
        MkDir strPath
    End If
    
    GetDirectory = strPath
End Function
Private Sub cmdSubmit_Click()
    Dim dbs As DAO.Database
    Dim strPath As String
    Dim varFile As Variant
    Dim i As Integer
    
    Set dbs = CurrentDb
    For i = 0 To lstFiles.ListCount - 1
        If lstFiles.Column(0, i) = 0 Then
            FileCopy lstFiles.Column(2, i), lstFiles.Column(3, i)
            dbs.Execute "INSERT INTO tblLinks (IRecordID, IPath, IDescription, Iissue) VALUES (" & lstFiles.Column(1, i) & ", '" & lstFiles.Column(3, i) & "', '" & lstFiles.Column(4, i) & "', '" & txtIssue.Value & "');", dbFailOnError
        End If
    Next i
    
    txtIssue.Value = ""
    
    While Not lstFiles.ListCount = 0
        lstFiles.RemoveItem 0
    Wend
    
End Sub
Private Sub Form_Load()
    RecordID = Forms!frm_home.Lab_Test_Input_Form.Form.AuditID
End Sub
Private Sub lstFiles_DblClick(Cancel As Integer)
    lstFiles.RemoveItem lstFiles.ItemsSelected(0)
End Sub
	Not sure I understand the question, please elaborate...
but then the line that puts the path into the database needs to put the where it is going to be not where is copied it from.
It uploads the files... creates the links and you are ready to access the pictures through a report or a form from there using a query.