Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA 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 November 5th, 2004, 10:00 AM
Authorized User
 
Join Date: Jun 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Linking files to an access table

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 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 from the subform.

Does anyone know how to do this? I have attached a code snippet which might help explain my situation. Yes - I know there's no error handling, I'll get round to that if i can sort this out :o)

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
    Else
      With objRst
       .AddNew
       !CSRRef = Me.Form!ID 'Capture id field insert into table to use as link
       !OLEDocumentType = ???????????? Need help here Ole filed to store class and link details
       !DocumentPath = varFileName
       !Date = Date
       !User = CsrUser()'Capture current user
       .Update 'Update the table
      End With
   End If
   objRst.Close
   Set objRst = Nothing
   Me.Requery 'Requery the form to update changes
End Sub

Cheers

William
__________________
William





Similar Threads
Thread Thread Starter Forum Replies Last Post
Linking to a Foxpro Table DavidWE Access VBA 0 July 18th, 2008 02:26 PM
Linking 2 data fields from 1 table aRtware Access 7 May 28th, 2006 11:23 PM
Linking opml/xml files to a html page helensobrien XML 0 February 21st, 2005 01:48 PM
Table designing and linking knight PHP Databases 0 January 17th, 2005 02:46 AM
Linking VB 6 form and Access table takawera VB Databases Basics 1 October 15th, 2004 09:12 PM





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