Attach file to record

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • calebmichaud@yahoo.com

    #1

    Attach file to record

    Hi

    I am having trouble understanding how to attach a file or files to a
    record. I want to (in form view0 allow the user to attach one or more
    than one file to the associated record, and then from then have the
    link displayed on the form. All the files would be displayed on the
    computers harddrive (or a network folder) and not in the db itself. I
    have read and reread http://www.mvps.org/access/api/api0001.htm
    and understand that i need to call the save as windows dialog box. but
    i dont understand the directions here. not knowing if it is code for a
    seperate module or if its code i put in the form (maybe a onclick
    event.)
    I would really appreciate some help or suggestions on this...maybe a
    sample db to look at. I am kinda new to this.
    Manyh thanks
    Caleb

  • pietlinden@hotmail.com

    #2
    Re: Attach file to record

    Caleb,
    Everything above the '***Code Start**** goes on the *form where you
    want to use the code*, like in a button's Click event..

    The rest goes into its own module.

    I have this code in my subform (Employees is the Mainform).
    txtFilePath is just a bound textbox control in my subform.

    This is an example of the FORM code...
    (the module you just leave as is!)

    Private Sub txtFilePath_Dbl Click(Cancel As Integer)
    Dim strFilter As String '<---What file extension(s) are you
    looking for?
    Dim strInputFileNam e As String

    strFilter = ahtAddFilterIte m(strFilter, "Excel Files (*.XLS)",
    "*.XLS")
    strInputFileNam e = ahtCommonFileOp enSave( _
    Filter:=strFilt er, OpenFile:=True, _
    DialogTitle:="P lease select an input file...", _
    Flags:=ahtOFN_H IDEREADONLY)

    Me.txtFilePath = strInputFileNam e
    End Sub

    Then the code in your form just calls the code in the module
    (ahtAddFilterIt em).

    If you are only ever attaching a *single* file, (Always, no exceptions,
    ever.), then you can just create a field in your parent table.
    Otherwise, create a child table and away you go.
    Does that help?

    Pieter


    calebmichaud@ya hoo.com wrote:
    Hi
    >
    I am having trouble understanding how to attach a file or files to a
    record. I want to (in form view0 allow the user to attach one or more
    than one file to the associated record, and then from then have the
    link displayed on the form. All the files would be displayed on the
    computers harddrive (or a network folder) and not in the db itself. I
    have read and reread http://www.mvps.org/access/api/api0001.htm
    and understand that i need to call the save as windows dialog box. but
    i dont understand the directions here. not knowing if it is code for a
    seperate module or if its code i put in the form (maybe a onclick
    event.)
    I would really appreciate some help or suggestions on this...maybe a
    sample db to look at. I am kinda new to this.
    Manyh thanks
    Caleb

    Comment

    • calebmichaud@yahoo.com

      #3
      Re: Attach file to record

      Pieter

      thanks for responding. let me see if i can suss this out.
      I run the possibility of attaching more than one file. So....
      Step 1. Create a new table to store the file names
      AttachmentID (pk)
      CompanyRepID
      FileName
      Step 2. Create a subform to implant on my main form. Maybe in
      datasheet view?
      This subform would have a boundtext box (filename) and a button with an
      onlick event of
      Private Sub txtFilePath_Dbl Click(Cancel As Integer)
      Dim strFilter As String '<---What file extension(s) are you
      looking for?
      Dim strInputFileNam e As String
      strFilter = ahtAddFilterIte m(strFilter, "Excel Files (*.XLS)",
      "*.XLS")
      strInputFileNam e = ahtCommonFileOp enSave( _
      Filter:=strFilt er, OpenFile:=True, _
      DialogTitle:="P lease select an input file...", _
      Flags:=ahtOFN_H IDEREADONLY)
      Me.txtFilePath = strInputFileNam e
      End Sub
      I take it this code brings up the windows save as dialog box. I have
      the possibilty though of attaching not only excel files but also word
      and pdf. i take it the strfilter needs to change accordingly. maybe
      to this? strfilter= ahtaddfilterite m(strFilter, "All Files (*.*)",
      "*.*") Is that right?
      Step 3.
      Take all the code under ***code start*** and create a module in the
      module section and call it.....openfile name
      Step 4
      Insert a code for double click to open the file name when it is
      displayed.

      I dont know if all this is right. For instance how do i make the file
      a hyperlink to be display in the subform....do i need to specify its
      text name.

      As you can see i am completly confused. But not as much as yesterday.
      :)

      thanks for your time.
      Caleb









      pietlinden@hotm ail.com wrote:
      Caleb,
      Everything above the '***Code Start**** goes on the *form where you
      want to use the code*, like in a button's Click event..
      >
      The rest goes into its own module.
      >
      I have this code in my subform (Employees is the Mainform).
      txtFilePath is just a bound textbox control in my subform.
      >
      This is an example of the FORM code...
      (the module you just leave as is!)
      >
      Private Sub txtFilePath_Dbl Click(Cancel As Integer)
      Dim strFilter As String '<---What file extension(s) are you
      looking for?
      Dim strInputFileNam e As String
      >
      strFilter = ahtAddFilterIte m(strFilter, "Excel Files (*.XLS)",
      "*.XLS")
      strInputFileNam e = ahtCommonFileOp enSave( _
      Filter:=strFilt er, OpenFile:=True, _
      DialogTitle:="P lease select an input file...", _
      Flags:=ahtOFN_H IDEREADONLY)
      >
      Me.txtFilePath = strInputFileNam e
      End Sub
      >
      Then the code in your form just calls the code in the module
      (ahtAddFilterIt em).
      >
      If you are only ever attaching a *single* file, (Always, no exceptions,
      ever.), then you can just create a field in your parent table.
      Otherwise, create a child table and away you go.
      Does that help?
      >
      Pieter
      >
      >
      calebmichaud@ya hoo.com wrote:
      Hi

      I am having trouble understanding how to attach a file or files to a
      record. I want to (in form view0 allow the user to attach one or more
      than one file to the associated record, and then from then have the
      link displayed on the form. All the files would be displayed on the
      computers harddrive (or a network folder) and not in the db itself. I
      have read and reread http://www.mvps.org/access/api/api0001.htm
      and understand that i need to call the save as windows dialog box. but
      i dont understand the directions here. not knowing if it is code for a
      seperate module or if its code i put in the form (maybe a onclick
      event.)
      I would really appreciate some help or suggestions on this...maybe a
      sample db to look at. I am kinda new to this.
      Manyh thanks
      Caleb

      Comment

      Working...