473,804 Members | 2,225 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

button attach file to Object OLE field

EJaques
8 New Member
(Using Access 2003)

I have a an Object OLE field in a table where users can insert Excel sheets, Word Docs, Pdfs etc.

I need to create a button on a formulaire that allows the user to browse for, select and attach the file. The file must appear as an icon that can be double clicked on to be opened. The file should be stocked in the DB.

I can make a dialog box appear and browse for the file and copy the path into the field using this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub AttachButton_Click()
  2.   Dim varFile As Variant
  3.  
  4.   With Application.FileDialog(msoFileDialogFilePicker)
  5.     With .Filters
  6.       .Clear
  7.     End With
  8.     .AllowMultiSelect = False
  9.     .InitialFileName = vbNullString
  10.     .InitialView = msoFileDialogViewDetails
  11.  
  12.     If .Show = True Then
  13.       For Each varFile In .SelectedItems
  14.         Me![File] = varFile
  15.       Next
  16.     Else
  17.       MsgBox "No file attached ! "
  18.     End If
  19.   End With
  20. End Sub
Thanks to: ADezii
(see http://bytes.com/topic/access/answer...ord-attachment)

But it needs to be an object sitting there, not just the path to the file.
Any help or alternative suggestions would be appreciated.

e
Aug 5 '09 #1
10 18988
ADezii
8,834 Recognized Expert Expert
@EJaques
Rather than go into a detailed explanation, I've created a simple Database and made it available to you as an Attachment. Clicking on the Insert OLE Object Command Button will:
  1. Open the Insert Object Dialog Box, from which you will:
    1. Select Create From File
    2. Browse ==> Select File to Insert ==> OK
    3. Select Display as Icon ==> OK
  2. The OLE Object will now be inserted into the OLE Object Field and displayed as an Icon.
  3. Double-Clicking on the Icon while in Form View will Open the File represented as an Icon in the Registered OLE Server for that File Type.
  4. No need for the File Dialog since the Insert Object Dialog will simply replace it.
  5. Good Luck, and Good Night!
Attached Files
File Type: zip OLE Object.zip (11.9 KB, 2490 views)
Aug 5 '09 #2
EJaques
8 New Member
Thank you that works very well
Aug 21 '09 #3
ADezii
8,834 Recognized Expert Expert
@EJaques
You are quite welcome.
Aug 21 '09 #4
kumar215
3 New Member
@ADezii
Can you pls provide the source code for the attachment, as I am new to VBA
Jun 15 '10 #5
ADezii
8,834 Recognized Expert Expert
@kumar215
  1. Download the Attachment
  2. Set the Display Type Property of the Bound Object Frame to Icon
Jun 15 '10 #6
kumar215
3 New Member
@ADezii
Thanks for reply, How can I get the file path name of file selected by using bound control ?
I need to show the complet file location in some text box.
Jun 16 '10 #7
ADezii
8,834 Recognized Expert Expert
@kumar215
Download the Attachment which should say it all.
Attached Files
File Type: zip OLE Object.zip (15.8 KB, 1143 views)
Jun 16 '10 #8
lfarias
1 New Member
Thank you so much! This was extremely helpful!
Feb 10 '12 #9
Hishow
14 New Member
Thanks a lot. Useful for me too
May 12 '16 #10

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

Similar topics

3
4848
by: Ben | last post by:
Hi all, i have file input field in a form like this: <input name="isbn" type="text" size="25" value="<?php echo $_POST ?>" /> <input name="image" type="file" size="25" value="<?php echo $_FILES ?>" /> when i press "submit" button, the same page gets loaded... if my $_POST is empty, i want to have the file path on "file input
0
1926
by: travis ray | last post by:
Hi, I have an extension in which a file object is created in python and passed down to a c extension which attempts to read from it or write to it. Writing to the file pointer seems to work okay, but reading from it results in EBADF. It also causes python to crash on exit. I've attached the minimal (I think) c code, python code, build script, build log, and run log. Any and all help is greatly appreciated.
0
1918
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id of the picture (an integer) and one (column named picture) is a field of type OLE Object which contains an image (it can store jpg, bmp, gif, but I don't know what image is stored inside). I want to retrieve the picture stored in the database and identified by a given id and display it in a web page (.aspx). I write in Visual C#, but it does...
1
1844
by: ohb | last post by:
Hello, is someone have a example of c# source of a service which is reading a attach file of an email.? Thank you. OHB.
2
1774
by: ohb | last post by:
Hello, Is it possible to parse a attach file in a email ? ohb
3
4376
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id if the picture (an integer) and one (column named picture) is a field of type OLE Object which contains an image (it can store jpg, bmp, gif, but I don't know what image is stored inside). I want to retrieve the picture stored in the database and identified by a given id and display it in a web page (.aspx). I write in Visual C#, but it does...
8
8934
by: Mark | last post by:
Hello. I am attempting to write binary data from a file to an OLE Object field, and then write the file back out from the database. I am reading and writing the files in binary mode, and using GetChunk and AppendChunk to read and write binary data from the OLE Object field. I am using VBA and DAO for this experiment. The OLE Object field is being used to store Long Binary data.
3
7186
by: Vibhu | last post by:
Hello All, I have a input box on the HTML page with the type set to file. What I want is that when the value changes in the file textbox, it should give me the full file path. I have even tried passing the value to a hidden control but all it does is passes only the File Name and not the file path. How do I go about it. I tried checking GMAIL service (Compose Mail) but all I could get is that they are passing the window and the file...
7
2736
by: RRsonawane11 | last post by:
Hello, Can anyone know how to write asp code to attach one file and email it to a specified email address. The attach file is the client choose from their Local Harddisk, just like we using yahoo mail or hotmail , allow us to attach file and sent it.
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9175
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3002
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.