Attaching objects to ole fields in tables
Hi All - I've been struggling for a while now trying to get a selected file to attach to an ole field in a table. I can capture all other info but can't get the class & source into the ole field. I'll try to explain what I'm doing - I have a form with a subform that tracks complaints, the main form has the general info on the case and the subform displays a table with a link (& other info) to related files (basically correspondance, word docs, pictures etc). I can browse for a file to attach using an api call, and I can capture the user, time, document path etc but I don't know how to put the source into the ole field of the table? - There are lots of examples on how to link to a form using object.sourcedoc but none that I know of with tables.
All I want to do is be able to launch the file/object from the subform.
Does anyone know how to do this? I have attached a code snippet which might help explain what I'm trying to do.
Private Sub AttachObject_Click()
Dim WmProject As Database 'Object database variable
Dim objRst As DAO.recordset 'Object recordset variable
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant 'Variable to hold file path
Set WmProject = CurrentDb ' Create a database object and assign current database to that object
'Create a recordset assign table and open table
Set objRst = WmProject.OpenRecordset("DocumentTable", dbOpenDynaset)
strFilter = "All Files (*.*)" & vbNullChar & "*.*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngflags = tscFNPathMustExist Or tscFNFileMustExist _
'Assign file path to variable
varFileName = tsGetFileFromUser( _
strDialogTitle:="Choose File To Attach")
If IsNull(varFileName) Then
!CSRRef = Me.Form!ID 'Capture id field insert into table to use as link
!OLEDocumentType = ???????????? Need help here Ole field to store class and link details for object.
!DocumentPath = varFileName
!Date = Date
!User = CsrUser()'Capture current user
.Update 'Update the table
Set objRst = Nothing
Me.Requery 'Requery the form to update changes