attachment button

J

John

Is there any way to create a button that allows the user to select a file,
and attach the content of the file to a particular database. I am trying to
create an issues database where with each issue entrie, user can attach a
..bin file that others can later download if they want. I saw some code
dealing with open/save files, but nothing was mentioned about actually
uploading a file that can attach to the database. Is this possible? I don't
want to just have a hyperlink, but the content of the file attached as a
"filed". Thank you.
 
T

Tom Wickerath

Hi John,
Is there any way to create a button that allows the user to select a file...

Yes. Are you comfortable using VBA code? You can use an API call to open a
common dialog, without having to use the common dialog control. While the
control takes a lot of the complexity out of the process, it's use introduces
too many problems, so most developers go for the API code method instead:

Call the standard Windows File Open/Save dialog box
http://www.mvps.org/access/api/api0001.htm

...and attach the content of the file to a particular database.

Do you mean embed the file (vs. linking)? Yes, this is also possible, but
not recommended due to the bloat in file size that is associated with OLE
Embedding. You are much better off to simply store the path + filename in the
database.
...but the content of the file attached as a "filed".

??? What is "attached as a filed"?


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Is there any way to create a button that allows the user to select a file,
and attach the content of the file to a particular database. I am trying to
create an issues database where with each issue entrie, user can attach a
..bin file that others can later download if they want. I saw some code
dealing with open/save files, but nothing was mentioned about actually
uploading a file that can attach to the database. Is this possible? I don't
want to just have a hyperlink, but the content of the file attached as a
"filed". Thank you.
 
T

Tom Wickerath

Fifi,

It wasn't clear to me that the original poster wanted to use e-mail. It
that's something that you want to do, then you can use SendObject to create a
message with an Access object attached. Don't try to call SendObject
repeatedly, in a loop, because it is known to fail. However, you can
concatenate a list of e-mail addresses into a string to send a list of people
the same message with an attachment. There are other methods to use if you
want to programmatically send an individual message with attachments to each
user.

What is it that you are looking to do?


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

how do we email the file once it is attached?
thank you
 
F

fifi

Thanks Tom,
but I tried SendObject earlier, but it doesn't have an attachment option. I
will try the 2 website, and hopefully it will work. Anyway, I will come back
if I have an issue
 
T

Tom Wickerath

Fifi,

SendObject is used to "Send" an "Object" as an e-mail attachment. An object
is considered a table, query, form, data access page, report , module or the
default, which is acSendNoObject. You didn't bother answering my question,
which was "What is it that you are looking to do?", so unless you are willing
to do that, I really cannot help you out.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Thanks Tom,
but I tried SendObject earlier, but it doesn't have an attachment option. I
will try the 2 website, and hopefully it will work. Anyway, I will come back
if I have an issue
__________________________________________

:

Fifi,

It wasn't clear to me that the original poster wanted to use e-mail. It
that's something that you want to do, then you can use SendObject to create a
message with an Access object attached. Don't try to call SendObject
repeatedly, in a loop, because it is known to fail. However, you can
concatenate a list of e-mail addresses into a string to send a list of people
the same message with an attachment. There are other methods to use if you
want to programmatically send an individual message with attachments to each
user.

What is it that you are looking to do?


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

how do we email the file once it is attached?
thank you
 
F

fifi

I am sorry for not responding to your question
Here is what I want to do: I have an attach file button on my form that
allow user to select a file they want to attach. Now I want my submit button
to be able to email the attached file whenever somebody click on it
Thank you for your help
 
T

Tom Wickerath

Hi Fifi,

Okay, here is a method that will work with Outlook, but not Outlook Express.
However, your user's will likely get the security warning message from
Outlook informing them that an application is attempting to send a message.

Using Automation in Microsoft Office Access 2003 to Work with Microsoft
Office Outlook 2003

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dno2k3ta/html/odc_ac_olauto.asp

Note: I think most of the code shown in this article will work with Office
2000 or Office XP (2002), although I haven't tested it to make sure. You will
need to set a reference to the appropriate Outlook library (version 9 for
Outlook 2000 or version 10 for Outlook 2002), although you should be able to
later convert working code to use late binding (no reference to the Outlook
X.X Object Library required).

How to use Automation to send a Microsoft Outlook message using Access 2000
http://support.microsoft.com/?id=209948

Microsoft Office 2000 automation Help file is available in the Download Center
http://support.microsoft.com/?id=260410

How to use a recordset to send Outlook e-mail to multiple recipients in
Microsoft Access
http://support.microsoft.com/?id=318881

The Office XP Automation Help file is available for download
http://support.microsoft.com/?id=302460

There are ways around the annoying security message, such as using Outlook
Redemption or a free ClickYes utility:
http://www.dimastr.com/redemption/
http://www.contextmagic.com/express-clickyes/

or using your own SMTP engine (ie. not using Outlook).
http://www.fairlogic.com/worldcast/
http://www.fmsinc.com/products/Emailer/index.asp


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

I am sorry for not responding to your question
Here is what I want to do: I have an attach file button on my form that
allow user to select a file they want to attach. Now I want my submit button
to be able to email the attached file whenever somebody click on it
Thank you for your help
 
F

fifi

Thank you so very much Mr. Tom,
I was able to run the module without error. Now my unique problem is where
do I type the sbSendMessage "C:\Documents and Settings\UserName\My
Documents\Customers.txt". The document said type it in the immediate window
in the Visual Basic Editor. But I don't know where?
 
T

Tom Wickerath

Hi Fifi,

I need to leave for work now, so I have to make this reply short.

To open the immediate window, open your database and then press the Ctrl
(Control) and G keys at the same time.

Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Thank you so very much Mr. Tom,
I was able to run the module without error. Now my unique problem is where
do I type the sbSendMessage "C:\Documents and Settings\UserName\My
Documents\Customers.txt". The document said type it in the immediate window
in the Visual Basic Editor. But I don't know where?
 
F

fifi

Thank you again Tom for your help. I bet you are like not her again.
Anyway, this is the problem that I am encountering now: my submit button has
a macro that uses SendObject to send a table on its click event. Now I
tried adding the sbsendmessage attachment pathname to the VB click event, but
it is not sending the attachment. I hope that I was clear. I don't want to
have a separate button to send the attachment. Do you a way I can send both
files with one button?
 
F

fifi

Tom, I am now able to send the table and a file at the same time. But I
still can't figure out how to write the argument for sbSendMessage so that it
will send the document that was attached to the form. What I have now, both
the name of the file and the path are fixed. And I don't want that.
I want the user to be able to send the attached file without having to
change everytime the file and the pathname always
Thanks
 
T

Tom Wickerath

Hi Fifi,
But I still can't figure out how to write the argument for sbSendMessage so
that it will send the document that was attached to the form.

Sorry, I meant to get back to you earlier, but I forgot. The sbSendMessage
subroutine includes an optional attachment path as a parameter. You can pass
this into the subroutine using a command button on a form, with the following
code included in the form's module. For this example, the name of the command
button is
"cmdSendMessage" and the name of the textbox on the form that includes the
full path to the file is "txtFilePath" (both without the quotes):

Option Compare Database
Option Explicit

Private Sub cmdSendMessage_Click()
On Error GoTo ProcError

Dim varFilePath As Variant

If Me.Dirty = True Then ' Save record first
Me.Dirty = False
End If

varFilePath = Me.txtFilePath
sbSendMessage varFilePath

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure cmdSendMessage_Click..."
Resume ExitProc
End Sub

In addition, I would make the following changes to the sbSendMessage
subroutine:

1.) Specify the type of parameter that you are passing into the subroutine
Sub sbSendMessage(Optional AttachmentPath As Variant)

2.) Change the line of code that reads:
If Not IsMissing(AttachmentPath) Then

to
If Len(AttachmentPath) > 0 Then


Good Luck,
Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Tom, I am now able to send the table and a file at the same time. But I
still can't figure out how to write the argument for sbSendMessage so that it
will send the document that was attached to the form. What I have now, both
the name of the file and the path are fixed. And I don't want that.
I want the user to be able to send the attached file without having to
change everytime the file and the pathname always
Thanks
 
F

fifi

I can't thank you enough Tom. You are a great help. I don't know what I
will do without you. Your suggestions are great. I am now able to send any
attachment, thanks to you.
 
Top