rookbird0234
New member
- Local time
- Yesterday, 17:25
- Joined
- Jul 16, 2009
- Messages
- 6
I'm trying to create a command button on a form that when clicked will allow a user to select an image to be inserted in an OLE frame bound to an OLE slot in the table the form is based upon. The form tracks a lot of data about part sets for a machine shop and our goal is to add pictures of complicated setups as needed. I am not sure where to begin. I have a code that opens a file dialogue box and inserts a hyperlink to the file the user selects but I don't think that is what I'm looking for here. I'll post that code and maybe some of you folks who tinker with OLE can shed some light on my situation.
Please find a sanitized copy of the database and have a look at frmLatheData. I have begun the work there with the OLE frames but haven't the slightest idea how to code the command buttons. Thanks!
Code:
Private Sub btnPic1_Click()
'variable declerations
Dim strFilter As String
Dim strInputFileName As String
Dim strInitDir As String
'Set the initial directory path
strInitDir = "H:\Pictures"
'Construct a filter for limiting the file types to those that are desired.
strFilter = ahtAddFilterItem(strFilter, "Bitmaps Files (*.BMP)", "*.BMP")
strFilter = ahtAddFilterItem(strFilter, "JPEG (*.JPG)", "*.JPG*")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
'Open the file dialogue for choosing the directory and set strInputFileName
'to the path of the chosen file.
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select a Picture...", _
InitialDir:=strInitDir, _
Flags:=ahtOFN_HIDEREADONLY)
'Here is where the name of the file is passed back to field and set as a
'Hyperlink. I want to pass the image into an OLE frame but I don't know
'What to send back nor how to do the syntax!
If Len(strInputFileName) > 0 Then
Me.Pic1 = "#" & strInputFileName & "#"
Me.Pic1.IsHyperlink = True
End If
End Sub