Macro to place attachment file to access?

stafire_18

Board Regular
Joined
Dec 8, 2004
Messages
162
is this possible? what i would like is a command button if it's click it'll give me the option to include a file from a location on my pc. would it be possible to save it to the database? or any suggestions on this?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
Don't quite understand what you want to accomplish. Are you trying to save a photo in the database? If so, which table do you want to save it to. What other fields are going to be in the table. Or, do you want to only save the address of the file within the database. There are so many different types of files available on a pc, trying to include any of these files into a database is not really a good way to gain access to these files.

Please try to expand the explanation of what you want.
 

stafire_18

Board Regular
Joined
Dec 8, 2004
Messages
162
just like a check mark box. that when i click it, it will then give me the option to add a file to the database just as an image file. I appologize if i'm not explaining this clearly. lets just go with a jpeg file. is there anyway to add a jpeg file to the database in a table or report or anywhere?
 

VicRauch

Well-known Member
Joined
Mar 23, 2006
Messages
2,032
Here is the code that I have done as a test some time back:
Code:
Private Sub Command4_Click()
    Dim conUserCancelled As Integer

    ' Error message returned when user cancels.
    conUserCancelled = 2001
    On Error GoTo ButtonErr
    If BoundOLE.OLEType = acOLENone Then
        ' No OLE object created.
        ' Display Insert Object dialog box.
        BoundOLE.Action = acOLEInsertObjDlg
    End If
    Exit Sub

ButtonErr:
    If Err = conUserCancelled Then ' Display message.
        MsgBox "You clicked the Cancel button; " _
            & "no object was created."
    End If
    Resume Next

End Sub
The table field that this OLE object is being put into is a "OLE Object" data type. It can be a Word document, a jpeg, a wave file, etc.
HTH,
 

Forum statistics

Threads
1,141,757
Messages
5,708,346
Members
421,566
Latest member
7Nabisco

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top