473,511 Members | 16,660 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Attachments

26 New Member
Background: Frontend MS Access 2010/ VBA; Backend MS SQL Server 2008. Learning Access VBA and SQL

I have an Access application that needs to have the backend DB store an attachment. The Access code is written in VBA. How can this be accomplished? I would like to do it much like a native Access program. Please see attachment.

The best I could find was to create the field in SQL as a varbinary(MAX).

Thanks in advance.
Attached Files
File Type: doc Doc1.doc (42.5 KB, 240 views)
Nov 4 '14 #1
4 2862
twinnyfo
3,653 Recognized Expert Moderator Specialist
From what I understand about SQL Server, it does not support attachment type fields in the same way as Access. It might be wisest to try to save the name and location of the file in a text field and then use that field as a pointer to open the file with its native program.
Nov 4 '14 #2
jforbes
1,107 Recognized Expert Top Contributor
There are two basic schools of thought when it comes to Attachments and SQL Server.

One is what Twinyfo is talking about, by saving the URL to the Attachment, typically in a NVARCHAR(255). This is probably the most common and definitely the easiest way. Then you can launch the URL with something like http://allenbrowne.com/func-GoHyperlink.html or something like this:
Expand|Select|Wrap|Line Numbers
  1. Function OpenAttachment(ByVal sTargetAndLocation As String) As Boolean
  2.     Dim dReturn As Integer
  3.     OpenAttachment = False
  4.     dReturn = Shell("explorer.exe " & sTargetAndLocation, vbNormalFocus)
  5.     If dReturn >= 0 Then OpenAttachment = True
  6. End Function
The other is to save the Attachment into a SQL field and this one is much trickier. Basically, it is using a BLOB/VARBINARY(MAX) or a hybrid type Blob (FileTables and FileStream if you want to Google them) to store the file into the SQL Server Database. I've done this in the past by using VB.NET's Filestream object to store into a VARBINARY(MAX), it was slick but it wasn't easy to figure out. It would be extremely difficult to replicate that code in MS-Access, so I really wouldn't recommend it unless it is a hard requirement. Oh, lastly, to use the Attachment you need to stream the Object back out of the Database into a physical file before it can be read by an external application.

The benefits of storing in SQL is that you wont have to worry about Windows Security on the physical file and you can have everything in one backup so you have little chance of loosing an Attachment. If you can live without these benefits, I would recommend saving the Attachment on a server somewhere and storing the URL in the Database.

I'm sure you'll find other opinions on this subject. Good luck.
Nov 4 '14 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
@jforbes,

Great explanation for our friend!

@CLSkcab,

Let us know what you decide and if there are any hitches as you go along.
Nov 4 '14 #4
CLSkcab
26 New Member
It is too complex for me at this time and it is a low priority item. Thanks anyway.
Nov 4 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2441
by: S_p_ike | last post by:
Hi all, I have a problem with mail with attachments. To send e-mail with attachments from a form, I use Setec Astronomy's libmail class (v 1.4) (available here http://www.phpclasses.org/) ...
1
8182
by: Trond A. S. Andersen | last post by:
Hi all, I'm working on a project in which i need to send mail attachments in the form of Excel documents from a .NET C# application. I've written a class which creates the Excel document using...
1
2323
by: nabil m | last post by:
hi i have 5 checkboxes i would like to when the user click on 1 or multiple checkbox i would like to email 1 or multiple files attachments to them ex: mailMsg.Attachments.Add(myAttachment+i); but...
5
1690
by: Jozef | last post by:
Hello, I have an Access XP database that has attachments to a BE database that has a password. The attachments work fine, until I run some code that modifies a BE table (adding a field). I do...
2
4519
by: Brad | last post by:
I have a web .Net app which sends emails with attachments. After the email is sent I clean up aftermyself and delete the attachments from disk. In upgrading to .Net 2 I changed the email logic...
1
2850
by: mike11d11 | last post by:
If someone could help me, I need to be able to send attachments from my access database that I have created. This database runs queries then generates a report off the queries from underlying...
1
399
by: Steve Holden | last post by:
I'm having some trouble getting attachments right for all recipients, and it seems like Apple's mail.app is the pickiest client at the moment. It doesn't handle attachments that both Thunderbird...
130
3229
by: Gianni Mariani | last post by:
Attached example CPP files makes it easier to post code and extract code from posts. It's unimaginable at this time where virtually any news reader is capable of dealing with attachments to stick...
1
3852
by: budyerr | last post by:
All, I am trying to build a email submission form using asp.net. I currently have a web form page that will upload to my webhosting server, attach to email then delete the file after sending. ...
17
2662
by: lonelykeyboard | last post by:
The database I have created needs a feature in which certain projects can be attached with certain specified PDF's. I have tried creating the following loop in order to search through a table...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7355
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5668
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.