未绑定的 OLE 对象控制器 - 通过 VBA 更改图片 - Microsoft Office Access
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6315890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unbound OLE object controller - Change picture via VBA - Microsoft Office Access
提问by fingerman
I have a table, in that table I have users something like this:
我有一张桌子,在那个桌子上我有这样的用户:
id username name password picture
now, I have a form, in that form I want to be able to show the picture in an unboundOle object. My situation requires use of an unbound object, so don't tell me about bound solutions.
现在,我有一个表单,在该表单中,我希望能够在未绑定的Ole 对象中显示图片。我的情况需要使用未绑定的对象,所以不要告诉我绑定解决方案。
Ok, now I need to change the value of this as something happens - I can get the picture from my table using DLookup(), But I don't know how to put the value in the controller with VBA.... what property do I use?
好的,现在我需要在发生某些事情时更改它的值 - 我可以使用 DLookup() 从我的表中获取图片,但我不知道如何使用 VBA 将值放入控制器中......什么属性我用吗?
Thanks, Fingerman.
谢谢,手指人。
回答by HansUp
I suspect what you want to do is not possible. Every attempt to alter the value of an unbound OLE control throws error 2774, "The component doesn't support Automation." So my best guess is it must be a bound control if you want to use automation with it. The only other possibility I can think of is to re-open the form in design mode (with VBA); perhaps then you could find some way to alter it.
我怀疑你想做的事情是不可能的。每次尝试更改未绑定的 OLE 控件的值都会引发错误 2774,“该组件不支持自动化”。所以我最好的猜测是,如果你想使用自动化,它必须是一个绑定控件。我能想到的唯一另一种可能性是在设计模式下(使用VBA)重新打开表单;也许那时你可以找到一些方法来改变它。
However, I've never attempted this before. When displaying an image on a form, I use an Image control rather than an OLE control. According to Microsoft, the Image control operates faster for images.
但是,我以前从未尝试过。在窗体上显示图像时,我使用 Image 控件而不是 OLE 控件。据微软称,图像控件对图像的运行速度更快。
Additionally I don't store the actual image in a table. Instead, I store the path to an image in the file system. It's easy to assign that external image to the image control from VBA. Prior to Access 2007, storing images in the database was notoriously inefficient. Supposedly, starting with 2007, there is a newer method available which is less inefficient, but I still don't use it.
此外,我不将实际图像存储在表格中。相反,我将图像的路径存储在文件系统中。从 VBA 将外部图像分配给图像控件很容易。在 Access 2007 之前,将图像存储在数据库中的效率是出了名的低效。据说,从 2007 年开始,有一种更新的方法可用,但效率较低,但我仍然不使用它。