Click here to Skip to main content
15,900,907 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings,

Kindly note that I`m developing a new Form linked to one table in Access2003 using VBA code in Macros. And what I need should be very simple idea to develop in VBA but I`m very new to VBA coding. So, please consider the following:

Workflow:
1- I created a table "Client" and I added a new field "Attachment" with OleObject datatype.
2- I created a new Form "Client Info" in order to add new clients details to the "Client" table and also read a specific rows (one client details) from that table in the form.
3- I have added two buttons to the "Client Info" Form in order to "Upload" & "Download" files to/from that OleObject field.
4- When clicking "Upload" button, an OpenFileDialog box should be opened to select the file that I want to store in the OleObject field.
5- When clicking "Download" button, a SaveFileDialog box should be opened and contains the file name from the stored OleObject corresponding to the same client.
6- Each time I enter a new client from the Form to the database, I want to add a file in the OleObject field of the "Client" table.

Questions:
1- How I can read the stored file corresponds to a specific client from the "Client" table?
2- How I can read the filename of the stored file corresponds to a specific client in order to use it as the filename of the SaveFileDialog?

Thanks in advance for any advice or help....
Posted
Updated 6-Sep-11 1:58am
v2

1 solution

I really do not recomend you to store files in MS Access database, becouse the database is growing as fast as it's possible. MS Access database (version 2003) has some restrictions[^], like size limited to 2 GB.

The simplest and the easiest way to store some files linked with database is to store them in the special folder (it can be inside the database directory), like ..\photos, ..\data, etc.

In the table you need to store only the full path to the file. If you wish, you can pack files, using - for example - 7z command line application[^]. This is useful when the free space of HDD is not to big.

If you still want to store files in the database, read this article[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900