Access OLE Fields
Thank You.
From: Steve Mansfield
Email: syberdyn@iglou.com
Organization: Syberdyne Systems
Set the DatabaseName and RecordSource properties of the data control to the database and table containing the OLE field that you wish to write bitmaps into. Set the DataField property of the picture control to point to the OLE field. Set the filter property of the Common Dialog control to "BMP Files|*.BMP". You should also add a few labels that are bound to some other fields in the table so that you can see which record you are currently viewing. Now, add the following code to the command button Click event:
CMDialog1.Filename = "" CMDialog1.Action = 1 If CMDialog1.Filename <> "" Then Picture1.Picture = LoadPicture(CMDialog1.Filename) End If
This will allow you to click the button for any given record and browse for a bitmap file. It then uses the LoadPicture function to set the selected picture into the picture property of the picture box. Because the picture box is bound this automatically writes that picture to the database whenever you move onto another record.
This is a quick and dirty way to write bitmap files into the Access database. You can add some error checking and a pile more functionality, but that should get you started. There are a number of third party custom controls available for displaying other graphic formats that also support this sort of binding. You might want to consider "ImageMan/VB" by Data Techniques (as advertised in The GUI Computing Catalogue) or "ImageKnife" by Media Architects.
Happy coding.