Ms access 在ms access中存储大量图像
我有一个库存/联系人数据库,我需要在其中存储大量图像(1万件物品,1万人)。现在,显然ole对象是不可能的,因为它完全膨胀了 有没有更好的方法来实现这一点,例如存储图像路径(将存储在数据库的文件夹中)并在需要的地方显示图像(这将非常好,因为有些项目是重复的)?有什么办法可以这样做吗?(另外,我真的需要一个文件浏览器来访问实际图像,而不是手动键入路径(那太糟糕了))这里有一个概念Ms access 在ms access中存储大量图像,ms-access,ole,Ms Access,Ole,我有一个库存/联系人数据库,我需要在其中存储大量图像(1万件物品,1万人)。现在,显然ole对象是不可能的,因为它完全膨胀了 有没有更好的方法来实现这一点,例如存储图像路径(将存储在数据库的文件夹中)并在需要的地方显示图像(这将非常好,因为有些项目是重复的)?有什么办法可以这样做吗?(另外,我真的需要一个文件浏览器来访问实际图像,而不是手动键入路径(那太糟糕了))这里有一个概念 Sub Locate_File() Dim fDialog As Office.FileDialog Di
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
您可能需要进行更改,并且必须使用Microsoft Office 12.0对象库才能使用FileDialog。大部分FileDialog代码取自存储路径可能是最好的方法,您可以使用
应用程序.FileDialog(msoFileDialogFilePicker)
对象获取路径。