473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Embed Image within DataBase

675 512MB
I have an image control on a form. I want to embed an image within the database for this control. How do I do that?

I started with a picture located in my computer at C:\Desktop\PicName and linked to that picture. I changed the PictureType to Embedded, but cannot remove the link to the picture without removing the picture from the control. Unless the link is valid, I cannot open the form. However, the correct picture is displayed in Design View even with a bad link.

Picture is .jpg (but I could change that)
Access 2003
Windows XP and/or Windows Vista - both computers up-to-date with sp's, etc.
Dec 27 '10 #1
9 6652
slenish
283 100+
Hello OldBirdman,

When using Images as long as you have Embedded selected the program will save a copy of the image to it. For some reason it still keeps the address which does not really matter because it does not link back to it for any reason so you dont really need to remove it. If its an address you dont want people to really see should they get to the backend I would just create a dummy folder move your images to that first then set up the Embedded image.

Hope that helps :D

Also make sure to try and scale down your image as much as possible or else you will see your DB size grow quickly if you are using a lot of really high rez images. One i was building went from 0 - 60mb and I did not have any info in it yet :D
Dec 28 '10 #2
OldBirdman
675 512MB
Thanks for replying.

I want to display 1 of 4 icons(images) to be determined within VBA code, and I want Access to store these images within the database.
I created 4 Image Controls, and embedded the icons within them using complete file names. I set PictureType = Embedded and Visible = No. To show an icon, I use:
Expand|Select|Wrap|Line Numbers
  1. imgShowLevel.Picture = imgLevel2.Picture
This works as long as the path to imgLevel2 is valid. If the path is not valid (the icon is no longer in my files as it is embedded within Access), the statement fails with "Run-time error '2220': Microsoft Office Access can't open the file 'C:\Desktop\PicName2.jpg'."
The answer then is to set 1 of the 4 hidden Image Controls to .Visible = True and not try to move the image to a 5th control.
OK, problem solved, but why can't I assign the property of one control to another?
Dec 28 '10 #3
slenish
283 100+
Hi OldBirdman,
Sorry took me a little while to write you back. I think I might be able to help you. A couple questions for you. The icon images do you only have one embedded image that you are trying to have change to another one? Or do ysou have many images and you are just trying to make certain ones visible? I would put all of your icon images on your form. Set them as visible = false then create a control that will make them visible as you click on the control. If you can attach a sample of what you are trying to do I can make adjustments for you :D I have a db where I built a really nice icon feature so I have sone experience with it.

If you have already fixed the problem then disregard.

Slen :)
Dec 30 '10 #4
OldBirdman
675 512MB
No problems Slen. What with weekends, holidays, & time zones, forums aren't the fastest way to communicate.
I want to learn how to use a Form as a Function, returning a value to the calling statement. I also want to use MsgBox with a CheckBox to "...not show this message again". This would allow me to use errors to teach use of a project with many errors caught, and as the operator learns, the warnings can be suppressed. So that is what I am trying to do.
To make my MsgBox similar to the familar M$ MsgBox, I want to add those icons that M$ uses, the ?, !, i, X. I can't find them in my computer, so I created them on the Desktop and called them Icon1.jpg, Icon2.jpg, Icon3.jpg, and Icon4.jpg. There could be more in the future. They are about 2K bytes each, no big deal. Then I created imgLevel1 and set .Picture to C:\Desktop\Icon1.jpg and .PictureType to Embedded. Same for imgLevel2, imgLevel3, and imgLevel4.
Code should be simple:
Expand|Select|Wrap|Line Numbers
  1. Select Case iLevel
  2. Case 1
  3.    imgShowLevel.Picture = imgLevel1.Picture
  4. Case 2
  5.    imgShowLevel.Picture = imgLevel2.Picture
  6. ...
  7. End Select
If the images still reside on the Desktop, the code works. But because I should no longer need these, I removed them from the Desktop, and the program errors, "Run-time error '2220': Microsoft Office Access can't open the file 'C:\Desktop\Icon1.jpg'."
There are work-a-rounds, sure. What comes to mind is to stack the permanent images in design view, and display the correct image with the .Visible Property at Run Time. If iLevel is 2, for example (see code above), then Case 2 would be:
Expand|Select|Wrap|Line Numbers
  1. imgLevel2.Visible = True
If this is the way to go, so be it. Either the controls have to be stacked, and therefore more difficult to work with in design view, or the form must stack them when Opened at Run Time.
Thank you for your attention !
Dec 31 '10 #5
slenish
283 100+
Hi OldBirdman,

Yea the holidays have made things a little hectic plus I started coming down with a cold so that hasn't made things any better :(

I would say the best way to do this would be to put your images permanently hidden in design view. One advantage to this is it helps keep things quick when the code goes to reference the image. It its kind of a pain to work with when they are stacked but saves you other pain down the road. Another thing you could do is use the move function when the image is visible this way you dont have to stack them you could have them layed out in the detail part of the form then just set the image1.move to where you want it to go once its becomes visible.

Sounds pretty cool what you are working on. I'll have to try and see if I can make a dummy example and you can take a look at it and we can figure out how to make it work the way you want it to :D
Jan 1 '11 #6
slenish
283 100+
Hi OldBirdman,

Ok I put together a little something. Im not quite sure if this is the idea you were having and its not fully working as of yet, but i whipped together something for you to kind of get a better idea of what you are trying to do. There is a msgbox that pops up if you are wrong but the dont display check box does not work yet. I dont want to build to much if Im way off base. But i built in some images for you and have them pop up if you do something right and a msgbox pop up if you do something wrong. I hope this helps you some! :D
Attached Files
File Type: zip ImageTest.zip (51.5 KB, 249 views)
Jan 1 '11 #7
OldBirdman
675 512MB
Slen - hope you're feeling better w/New Year :)

Thanks for the sample. For the image handling, logically similar to mine, as I would expect. The images are obviously embedded, because they were visible when I ran your Access program "Image Test".
I added the line of code:
Image0.Picture = Image2.Picture
in the Select Case ... Case 1 code. This line of code cannot be executed. The same error occurs as detailed in my post #3, except that the file is "C:\Documents and Settings \C;\Documents and Settings\slenish\Desktop\....." Imagine that. Access can't find your desktop from my computer. Oh well (sigh).

But seriously, if Image2.Picture is a valid property, containing an embedded image at run-time, why can't it be assigned to another control with the .Picture property?

I tried
Image0 = Image2
figuring I could then assign .Left and .Top to put it back where it belongs. Doesn't work. "Run-time error '438': Object doesn't support this property or method"

For now, I will use the simple method of creating enough controls and making them .Visible = True as necessary. I won't try to put the same image in each corner of a form, or something equally complex.

I'm attaching my progress so far. Still needs some work with the form width & height, and centering text, but for the goals stated in Post #5, I'm satisfied.
Attached Files
File Type: zip myMsgBox.zip (39.2 KB, 148 views)
Jan 2 '11 #8
slenish
283 100+
Hi OldBirdman,

Hope you didnt think i forgot about you! Well im staring to feel better now and got a chance to look over your file. Have to say I like the way its looking very nice!

Well I rebuilt your images for you a little bit and tried something different that you may like so you dont have to stack them all in one place. I was having some trouble getting them to pop up so what I did was comment out some of your code and built the function in to your buttons on the pop up message (hope you dont mind). All you have to do is press the different buttons and each image will appear. If you look on the back you will see I moved all of your images below the buttons so you can see them but when they open they move to where you want them.

Also I was researching more in to embeding images and found out something about setting images as OLE objects. It sounds little more complex and may not be worth doing if you only have a few icon images but could be something to look in to down the road. I have to play around with it myself more to see how to actually make it work.

Also if you want any other help with this project let me know looks pretty cool wouldnt mind putting my own skills to the test.

anyway let me know what you think

later

Slen :D

link: http://office.microsoft.com/en-us/ac...005280225.aspx
Attached Files
File Type: zip myMsgBox.zip (120.5 KB, 152 views)
Jan 5 '11 #9
slenish
283 100+
I made some adjustments

:D
Attached Files
File Type: zip myMsgBox.zip (113.0 KB, 204 views)
Jan 6 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: day | last post by:
I'm trying to use a non-scrolling background image within a div (the non-scrolling part is a "nice-to-have" vs a "have to have"). The style for that is: <div style="height=400px;...
0
by: Andy | last post by:
Is it possible to embed an Access Database into a C# Windows Application, much like you would for a Resource File? If it is possible: Is there any advantage / disadvantage to doing this? How...
1
by: feudalac! | last post by:
I have an app that uses MySql as a data source... I would like to embed a SQL database into the app so it could be used without a database server connected to the network. I couldn't find any...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
3
by: peter.chase | last post by:
In my Web application, a have an image within a DIV. One of the allowed user gestures is to drag the image with the mouse. When dragging, parts of the image that would otherwise be displayed...
0
by: santybanty20 | last post by:
i have some problem on ilplementing the code for the insertion of image into database that didnot get how to use the code for image storege.so can u help me in the use for the code by which i want to...
1
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi EveryBody: I have the following code that I used in my application to retive image from database: Dim cnn As New SqlConnection("Data Source=localhost;Initial Catalog=Husam;Integrated...
2
by: keerthisreenu | last post by:
hai to all...!! iam working with Ms Access 2000. iam saving an image in the database. After that i want to retrive the same image from database and displaying it in the picture box. but its not...
3
by: brijesh1234 | last post by:
dear Sir/madam I am getting a problem while displaying a image from database Database : MSSQL2000 I have a table named “Image” having following fields as ImageId int Image Image
4
selvasoft
by: selvasoft | last post by:
Hi Please help me i want display all images from my database. but here my code that will display only one image from database. But i want all images, any one help me. <html> <head>...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.