MikeORTEC
asked on
Putting pdf or other binary file into access database
I am developing an application using VB DAO, using an access database to store/retrieve data. I would like to be able to store files in fields. How do I create the fields so that they can accept files and how do I write the SQL to store them in the database?
ASKER
Thanks for the caveat. How do I go about storing the path and then letting the user open the file. My guess is taht I create a text field and then use a common dialog to allow the user to store the file whereever they want and then somehow keep track of the path in string format to store? Could you please explain in more detail. Thanks!
the path is simply a string, and you can usually capture that path when you allow the user to identify the file to be stored. Yes, you can use the Common Dialog control to do that.
If you need to open the PDF, pointed to by the path, then you need to execute the Adobe Acrobat Reader, passing it the path of the PDF to be opened.
What kind of file are you going to be useing for this application?
AW
If you need to open the PDF, pointed to by the path, then you need to execute the Adobe Acrobat Reader, passing it the path of the PDF to be opened.
What kind of file are you going to be useing for this application?
AW
ASKER
I would like to store pdfs and word doc files. I have not done this before, so I could use some example code to close the issue. I have invoked excel with something like:
'create the spreadsheet
Dim MyExcel As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set MyExcel = New Excel.Application
Set xlBook = MyExcel.Workbooks.Add
Set xlSheet = xlBook.Worksheets(3)
MyExcel.Application.Visibl e = False
numrecords = sp.RecordCount
Dim i As Long
i = 0
With xlSheet
.Activate
'put the names of the columns in the first row of the control
Code to put stuff where I want it
End With
MyExcel.Application.Visibl e = True
frmQAChart.WindowState = vbMinimized
Screen.MousePointer = vbDefault
I am guessing that invoking the application is similar for word or adobe. I also figure that I need to handle "what if there is no adobe or word" on the computer that the application is running on.
Thanks for your help.
'create the spreadsheet
Dim MyExcel As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set MyExcel = New Excel.Application
Set xlBook = MyExcel.Workbooks.Add
Set xlSheet = xlBook.Worksheets(3)
MyExcel.Application.Visibl
numrecords = sp.RecordCount
Dim i As Long
i = 0
With xlSheet
.Activate
'put the names of the columns in the first row of the control
Code to put stuff where I want it
End With
MyExcel.Application.Visibl
frmQAChart.WindowState = vbMinimized
Screen.MousePointer = vbDefault
I am guessing that invoking the application is similar for word or adobe. I also figure that I need to handle "what if there is no adobe or word" on the computer that the application is running on.
Thanks for your help.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Great! Thanks!
A file (such as a PDF or a JPEG/TIFF) wolud be stored asan OLE Object, and that means that what is actually stored in the table is approximately 3 times (yes 3) as large as the file itself - becuase of the OLE wrapper that is also stored (by the nature of OLE Objects stored in Access Tables).
In addition, any changes to the object itself, would lead to Database BLOAT, as Access does not do a particualry good job of clean up of 'garbage' space - this only occurs when the database is Compacted.
AW