Wrox Programmer Forums
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 8th, 2004, 08:21 AM
Authorized User
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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 _
    Or tscFNHideReadOnly

   'Assign file path to variable
   varFileName = tsGetFileFromUser( _
   fOpenFile:=True, _
   strFilter:=strFilter, _
   rlngflags:=lngflags, _
   strDialogTitle:="Choose File To Attach")

   If IsNull(varFileName) Then
      With objRst
       !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
      End With
   End If
   Set objRst = Nothing
   Me.Requery 'Requery the form to update changes
End Sub



Similar Threads
Thread Thread Starter Forum Replies Last Post
How access fields of objects stored in Array List rfinks VB How-To 2 July 11th, 2006 06:00 PM
How to add linked tables objects to this query ? method Access 1 July 30th, 2005 01:54 AM
Attaching Tables!!! NitinJoshi General .NET 3 January 21st, 2005 11:50 PM
OO4O (Oracle Objects for OLE) SteVader Classic ASP Databases 0 June 6th, 2003 07:33 AM
OO4O (Oracle Objects for OLE) SteVader Classic ASP Components 0 June 6th, 2003 04:08 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.