S_Hannah Posted March 22, 2012 Posted March 22, 2012 Hi, I am hoping someone can point me in the right direction. My database has a 'Photo' Column and in that column it would have text i.e. DSC-0001. That photos would be stored within a directory i.e. C:\Images and at present staff have to browse to the images directory to see the photo. Is there a way of having they DB store the DSC-0001.jpg and there be code in the BG that would know what to do with the image i.e. show the images in a container but put the prefix of C:\Images\[db value] If anyone could help, I would be ever so greatful
mac_shinobi Posted March 22, 2012 Posted March 22, 2012 (edited) If MS Access then you could create a form and use some vba code to populate the image or picture object from the relevant text field that contains the image name ie if the picture box was called imgPicture, the text field that contained the name of the image was txtImage then you could have something like You would probably have some code like below in both the previous and next buttons underneath the relevant code to make the form go between the records Obviously syntax may be slightly different on how you load the image into the picturebox etc but you get the jist Dim strPath As String strPath = "C:\Images\" & txtImage.Value & ".jpg" imgPicture.LoadPicture(strPath) Edited March 22, 2012 by mac_shinobi
S_Hannah Posted March 22, 2012 Author Posted March 22, 2012 Hi Sorry, Too busy tyring to write this up, makes sence in my head. I am just using an Acess 2010 database. And the images are just within a directory and I would like the DB to read from there.
mac_shinobi Posted March 22, 2012 Posted March 22, 2012 (edited) Just edited my above post Hopefully the above is what you were after ? Might be able to insert said code into the form load event or a different event instead of having it twice ( once for previous and once for next button ) ?? That or maybe make your own sub and have that code in said sub so you are calling it when required Edited March 22, 2012 by mac_shinobi 1
S_Hannah Posted March 22, 2012 Author Posted March 22, 2012 mac_shinobi, Thank you for your help, really appreciate it. Given a huge Access Database, but not done this sort of thing for years! Code used was: Dim strPath As String strPath = "C:\Images\" & txtImage.Value & ".jpg" imgPicture.Picture = strPath Once again, Thank you. 1
S_Hannah Posted March 22, 2012 Author Posted March 22, 2012 I have implemented the code and it works great however when I click next it still shows the old image, even when the code has been applied to the next button. Any Ideas? Stu
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now