Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old December 11th, 2006, 08:25 PM
calebmichaud@yahoo.com
Guest
 
Posts: n/a
Default 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

  #2  
Old December 11th, 2006, 09:45 PM
pietlinden@hotmail.com
Guest
 
Posts: n/a
Default 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_DblClick(Cancel As Integer)
Dim strFilter As String '<---What file extension(s) are you
looking for?
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)",
"*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

Me.txtFilePath = strInputFileName
End Sub

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

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@yahoo.com wrote:
Quote:
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
  #3  
Old December 12th, 2006, 01:15 PM
calebmichaud@yahoo.com
Guest
 
Posts: n/a
Default 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_DblClick(Cancel As Integer)
Dim strFilter As String '<---What file extension(s) are you
looking for?
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)",
"*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
Me.txtFilePath = strInputFileName
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= ahtaddfilteritem(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.....openfilename
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@hotmail.com wrote:
Quote:
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_DblClick(Cancel As Integer)
Dim strFilter As String '<---What file extension(s) are you
looking for?
Dim strInputFileName As String
>
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)",
"*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
>
Me.txtFilePath = strInputFileName
End Sub
>
Then the code in your form just calls the code in the module
(ahtAddFilterItem).
>
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@yahoo.com wrote:
Quote:
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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles