Openning a image in the form, and pop up in a window

qnikchen

Registered User.
Local time
Yesterday, 20:46
Joined
May 2, 2013
Messages
13
Hi Everyone,

I am new to VBA for access. I am working on a form as a user interface. I have added an picture to the form and it will change, according to the selection in the combobox. It looks small, and not clear because of the size, and each image has different sizes. I would like to know if there is a a way that will allow me to click on it, and then it will open in another window so it is bigger with the right sizes. I was thinking that it could be something in the on click event. I have been searching on the internet and I have not found anything :confused:


Thanks, any help or suggestion would be very appreciatted.
 
Not sure if that can be done since how will access know what are the right sizes?

However the following will open the file in an appropriate program based on the file suffix

in a module put

Code:
Public Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

in a suitable event on your form (button click or image doubleclick for example) put

Code:
Dim L as Long
L = ShellExecute(0, "Open", """" & ImageFilePath & """", vbNullString, vbNullString, 1) [COLOR=darkolivegreen]'where ImageFilePath is the path to your image[/COLOR]

I use this because I store images in a directory rather than the DB to prevent bloat - and instead of an OLE object field I just have a text field which stores the ImageFilePath

I haven't tried it but you could try replacing ImageFilePath with the source declared in your image control since it is the suffix that matters
 
You could try creating a several form as a pop-up and size this to the aspect you require.

Then it is a simple matter to call this form qualifying this with the current record.

Simon
 
You could try creating a several form as a pop-up and size this to the aspect you require
The problem with this is knowing what size
 
there has to be some consistency. It will never be perfect as a 500px x 100px or 100px x 500px have totally opposing aspects. However an Image control will fit the image into the "container" as best it can. I supposed the answer lies into creating a Image Control big enough for the purpose. Web sites don't present 5,000px x 5,000px because it is simply to big. I would max at between 500px and 750px. If you make a real small Image Control using an Image that is too big you often lose definition as it is "crunched down".

Have a look at your image assets vs the average screen size of users and make a judgement. It is not as though manipulating the Image Control's height and width are that onerous.

Simon
 
Hi CJ, Simon,

Thanks both for replying me back for my inquiry. My form have a combobox to select record that you want to look. Roughly there are more than 20 images. They are as the OLE file. I cannot leave in the directory because this database will be used by many users at different computer. Currently my picture are in a subform. I'll be trying all the different ways that you guys have mentioned.

CJ, I have tried to understand your code

Code:
Dim L as Long
L = ShellExecute(0, "Open", """" & ImageFilePath & """", vbNullString, vbNullString, 1) [COLOR=darkolivegreen]'where ImageFilePath is the path to your image
[/COLOR]

can you explain a little bit more about the imagepilepath? would that be the same as having the picture in document? How can I obtain it? Sorry very new to access.

Thank you
 
I've done a bit more investigating - you haven't said if your images are in bound or unbound controls so this covers all eventualities

If you have a bound object frame control then simply double clicking on it will open it in a new window suitable for the image (if a pdf then pdf viewer, if an image then new picture/fax window, if an excel object then excel, etc)

If you are using an unbound object frame control (let's say it is called myImage) then use the code as already supplied in the doubleclick event of myImage (also don't forget the public declaration of ShellExecute in a module) and substitute 'ImageFilePath' with 'myImage.Picture' and it will open in a new window as above

If you are using an unbound image control then do as per my original post
 

Users who are viewing this thread

Back
Top Bottom