
How do I determine Class property
Hi,
I have a table "tblImage" with a field containing the full path to a
bitmap image on my hard drive (.gif, .jpg or bmp).
Table: tblImage
------------------------
Field Name: filename
Data Type: Text
Field Size: 255
Field Name: image
Data Type: OLE Object
I want to add the actual bitmap data to a field in the same table.
Using the AutoForm: Columnar Wizard, create a new form based on the tblImage
table. Save it as frmImageLoad.
Open the frmImageLoad form in Design view.
Type the following event procedure in the OnLoad property of the
frmImageLoad form:
Private Sub Form_Load()
Do While Me!filename > ""
Select Case Right(Me!filename, 3)
Case "jpg"
[image].Class = "jpegfile"
Case "gif"
[image].Class = "giffile"
Case "bmp"
[image].Class = "Paint.Picture"
End Select
[image].OLETypeAllowed = acOLEEmbedded
[image].SourceDoc = [filename]
[image].Action = acOLECreateEmbed
DoCmd.RunCommand acCmdRecordsGoToNext
Loop
End Sub
Save the frmImageLoad form and open it in Form view.
All files that match the [filename] you entered are added to the tblImage
table.
Please see the following article in the Microsoft Knowledge Base:
Q158941 ACC: How to Load OLE Objects from a Folder into a Table
http://support.microsoft.com/support/kb/articles/q158/9/41.asp
So long!
Serge Gavrilov.
http://accesstools.narod.ru
Quote:
> Does anyone know how I can retrieve the Class property of
> an embedded OLE object via VBA from the form code.
> It seems from the on-line documentation that the 'Class'
> property can be retrieved as a string from the object.
> In my code below I have a field called 'image' that is an
> OLE object (this code is from the form). Whenever I run it
> I get a blank string returned from '[image].Class'
> Any ideas?
> ----------------------------------------------
> Private Sub btnSave_Click()
> Dim classText As String
> classText = [image].Class
> MsgBox ("Here's the class: " & classText)
> DoCmd.RunCommand (acCmdSave)
> End Sub
> -----------------------------------------------