473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

Dec 11 '06 #1
2 7800
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
ca**********@yahoo.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
Dec 11 '06 #2
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



pi********@hotmail.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_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
ca**********@yahoo.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
Dec 12 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: tabonni | last post by:
Hi I try to grab the checked files from HTML page and then send those PDF files as attachments. It can just send email, there are no PDF files attached. Can anybody point out my error? My...
1
by: RickL | last post by:
How do you attach a file to a hyperlink so that it cab be opened when clicked? I am new to .net and web development and I need to attach a file to an asp page so that when click it can be opened it...
5
by: erez | last post by:
Hello How can i attach an html file to TableRow in HtmlTable control that run at server, the code should be in server side. thanks
1
by: kevcar40 | last post by:
i have a form that i want to attach files to as hyperlinks the problem is there could be upto 10 files attached to the form or maybe none How can i go about 1 creating the attachements and...
7
by: Greg P | last post by:
I know this is a long post, please bear with me. I have been working on this all weekend to no avail although I have done a good amount of research (see most pertinent links that I've looked at...
6
by: a | last post by:
What is the best way to construct an email in python and also attach a html file the html file to be attached is not on disk, but should be dynamically constructed in the python script I want...
0
by: Lexxzy | last post by:
Hi to all, I've a problem about to attach a recovered database file in the enterprise manager. My problem goes this way, I want to attach a recovered database file. So when I followed this...
14
by: sreemathy2000 | last post by:
My requirement is to generate and attach a file and send in an email automatically. i have a existing functionality where i using the code below to write a CSV file in my local system. ...
9
by: dpatel75 | last post by:
I am trying to copy a database from a SQL 2000 SP3 Windows 2000 server to a 2005 SP2 Windows 2003 server. I am trying to use detach and attach method (have tried both within Management Studio and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.