I have an issue, I think I have a work around, but I am struggling...
Firstly, I have a SQL 2012 database which has a table holding some images. These images have to be stored in the database (as we are using them in Android devices as well as Access) and so I cannot use paths to the images.
We have an Access 2010 front end which is linking to this SQL 2012 database. The images which are loaded can be displayed in Access, but only one at a time. They can be displayed by putting some code in the Form_Current event: -
So far, so good.
However, I need to display a form with multiple images at the same time. I don't want to be a bad coder and have a single form with lots of image controls (as I do not know how many image controls I may need). What I really want to do is to use the built in Continuous Form feature of Access. However, as we all know, the image control only displays different images if you can use an image path (which I don't have).
My work around: -
These are small images - no more than 100kb. When the user clicks to view this particular form they are able to wait a few seconds. My thoughts are: -
1. Create a temporary local table to hold the SQL Data in Access
2. Push the SQL data into the local table.
3. Create "on the fly" the actual image files (based on the image data) and update this local table with the path to these images.
4. Reference the path to these images on the Picture Control and hey presto it will work on a continuous form!
The problem
Although the images are valid, when I dump out the image data to a local file it is not valid and I cannot view the file (in paint etc).
I am not an expert on creating binary image files. I thought it would just be create a file with the same contents and away you go. This is my code: -
Am I missing something fundamental here? :banghead:
Firstly, I have a SQL 2012 database which has a table holding some images. These images have to be stored in the database (as we are using them in Android devices as well as Access) and so I cannot use paths to the images.
We have an Access 2010 front end which is linking to this SQL 2012 database. The images which are loaded can be displayed in Access, but only one at a time. They can be displayed by putting some code in the Form_Current event: -
Code:
Private Sub Form_Current()
Image0.PictureData = MealImage
End Sub
So far, so good.
However, I need to display a form with multiple images at the same time. I don't want to be a bad coder and have a single form with lots of image controls (as I do not know how many image controls I may need). What I really want to do is to use the built in Continuous Form feature of Access. However, as we all know, the image control only displays different images if you can use an image path (which I don't have).
My work around: -
These are small images - no more than 100kb. When the user clicks to view this particular form they are able to wait a few seconds. My thoughts are: -
1. Create a temporary local table to hold the SQL Data in Access
2. Push the SQL data into the local table.
3. Create "on the fly" the actual image files (based on the image data) and update this local table with the path to these images.
4. Reference the path to these images on the Picture Control and hey presto it will work on a continuous form!
The problem
Although the images are valid, when I dump out the image data to a local file it is not valid and I cannot view the file (in paint etc).
I am not an expert on creating binary image files. I thought it would just be create a file with the same contents and away you go. This is my code: -
Code:
Dim nFileNum As Integer
nFileNum = FreeFile
Open "c:\Test.bmp" For Binary Lock Read Write As #nFileNum
Put #nFileNum, , MealImage.Value
Close #nFileNum
Am I missing something fundamental here? :banghead: