PDA

View Full Version : Want Button on Access Form for Inserting OLE Object into Table


linkinfinity
Apr 10, 2008, 08:10 PM
Hi.

I'm looking for a simple simple simple solution that will allow me to add a button to an Access form. When the button is clicked, a File Dialog box should appear allowing me to pick any file to insert into the OLE package.

I've searched every corner of the web and have found a lot of suggestions that are close, but most are either too complex (using API) or are focused on something specific (like inserting .xls files only).

Can anyone help?

Much appreciated!

ScottGem
Apr 11, 2008, 05:54 AM
The answer is using the API. Sorry, but there is no simple way. If you use the Code here:
API: Call the standard Windows File Open/Save dialog box (http://www.mvps.org/access/api/api0001.htm)

You can do this (its what I use). Its not that difficult. The code behind your button would look like this:

strInputFileName = ahtCommonFileOpenSave(InitialDir:="K:\Transcar", _
Filter:=strFilter, OpenFile:=True, Flags:=ahtOFN_HIDEREADONLY, _
DialogTitle:="Select File for Input...")

This opens the File>Open dialog to the folder K:\Transcar. You can leave out the Filter argument if you want to show all files.