storing large numbers of images in ms access

后端 未结 1 2001
忘了有多久
忘了有多久 2021-01-26 08:42

I have a inventory/Contact database where I need to store a lot of images (10k items, 1k people). Now, obviously ole object is out of the question due to the sheer bloat.

<
相关标签:
1条回答
  • 2021-01-26 09:32

    Here is a concept

    Sub Locate_File()
       Dim fDialog As Office.FileDialog
       Dim file_path As String
       Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
    
       With fDialog  
        'Set the title of the dialog box.
        .Title = "Please select one or more files"
    
        'Clear out the current filters, and add our own.
        .Filters.Clear
        .Filters.Add "All Files", "*.*"
    
        '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
           file_path = .SelectedItems(1)
           Copy_file(file_path,Right(file_path, Len(file_path) - InStrRev(file_path, "\")))
        Else
           MsgBox "You clicked Cancel in the file dialog box."
        End If
      End With
    End
    
    Sub Copy_file(old_path As String, file_name As String)
      Dim fs As Object
      Dim images_path As String
      images_path = CurrentProject.Path & "\images\"
      Set fs = CreateObject("Scripting.FileSystemObject")
      fs.CopyFile old_path, images_path  & file_name
      Set fs = Nothing
      'Update your database with the file location of images_path & file_name
    End
    

    You may need to make changes and you must require the Microsoft Office 12.0 Object Library for FileDialog to work. Much of the FileDialog code was taken from Microsoft

    0 讨论(0)
提交回复
热议问题