Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Need to use VBA to put image on a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Earl Kiosterud - 08 Jun 2007 04:23 GMT
Hello folks,

I need to have an event-fired sub put an image on a form.  It needs to be fired when the
form is advanced to the next record.  I don't know how to code it.  Thanks

Signature

Earl Kiosterud
www.smokeylake.com

Earl Kiosterud - 08 Jun 2007 04:44 GMT
I think that was a bit too terse.  The image I want to put on the form is a jpg image, the
file name of which I'll be able to get from a field in the record in the associated table.
There's an image for each record.

Signature

Earl Kiosterud
www.smokeylake.com

   Note: Some folks prefer bottom-posting.
   But if you bottom-post to a reply that's
   already top-posted, the thread gets messy.
   When in Rome...
-----------------------------------------------------------------------

> Hello folks,
>
> I need to have an event-fired sub put an image on a form.  It needs to be fired when the
> form is advanced to the next record.  I don't know how to code it.  Thanks
Rob Parker - 08 Jun 2007 05:37 GMT
Hi Earl,

Use an Image control to display the photo, and place code like the following
in the Current event of the form.  This assumes that the path/filename of
the image file
is in a textbox control named txtImageFile, bound to the table field where
the path/filename is stored.  I use the same code in the AfterUpdate event
of the textbox to update the picture if the path/filename is changed.

 If Not IsNull(Me.txtImageFile) Then
   Me.imgImage.Picture = Me.txtImageFile
 Else
   Me.imgImage.Picture = ""
 End If

If you don't want to have the image filename visible on your form, you can
hide the textbox control, or simply refer to the field in the code, rather
than to the control holding the field's content; in that case, the first
line would be:
   If Not IsNull(Me!ImageFieldName) Then

And another tip - if you set the Size Mode of the image control (it's on
the Format tab in the Properties dialog) to Zoom, your image will resize to
fit the control, and retain its aspect ratio.

Finally, to prevent possible crashes when scrolling through records, you
should incorporate the registry changes described here:
http://www.mvps.org/access/api/api0038.htm

HTH,

Rob

>I think that was a bit too terse.  The image I want to put on the form is a
>jpg image, the file name of which I'll be able to get from a field in the
[quoted text clipped - 5 lines]
>> fired when the form is advanced to the next record.  I don't know how to
>> code it.  Thanks
Earl Kiosterud - 08 Jun 2007 16:08 GMT
Rob,

Worked great.  Thanks.  I got questions -- you got answers!  Only this ain't Radio Shack.

I changed the Picture Type property to Linked (don't need to keep it in the data base).  I
added code to check for the existence of the image file and reset the image
(Me.Image15.Picture = "") if it doesn't exist.

Is there a control that will let me increase the size of the image, then use scroll bars to
pan around?  I've looked at all the properties of the Image control that I'm using now, and
I don't see anything.

Signature

Earl Kiosterud
www.smokeylake.com

   Note: Some folks prefer bottom-posting.
   But if you bottom-post to a reply that's
   already top-posted, the thread gets messy.
   When in Rome...
-----------------------------------------------------------------------

> Hi Earl,
>
[quoted text clipped - 35 lines]
>>> I need to have an event-fired sub put an image on a form.  It needs to be fired when the
>>> form is advanced to the next record.  I don't know how to code it.  Thanks
Rob Parker - 09 Jun 2007 02:19 GMT
Hi Earl,

Glad it's working.  As for your latest question: the standard image control
(or the bound or unbound OLE controls) does not let you resize, or provide
scrollbars.  You set it to the size you want your image to display at
on-screen, and that's it.  As I said in my earlier post, if you set the size
mode to zoom, your image will always be displayed fully (ie, not clipped,
and possibly expanded to fit but still retaining its original aspect ratio).

There may be a third-party control which will do what you want, but I'm not
aware of any.

Rob

> Rob,
>
[quoted text clipped - 53 lines]
>>>> be fired when the form is advanced to the next record.  I don't know
>>>> how to code it.  Thanks
Stephen Lebans - 09 Jun 2007 03:03 GMT
HI Rob,
the OP can place an Image control, sized to 22. in x 22 in. on a form sized
the same. In this way the form's native ScrollBars can be used to scroll the
contents of the Image control. For a sample MDB using this method see:
http://www.lebans.com/loadjpeggif.htm

Signature

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

> Hi Earl,
>
[quoted text clipped - 68 lines]
>>>>> be fired when the form is advanced to the next record.  I don't know
>>>>> how to code it.  Thanks
Rob Parker - 09 Jun 2007 04:52 GMT
Hi Stephan,

Thanks for that advice.  The sample is great - very clever.

Rob

> HI Rob,
> the OP can place an Image control, sized to 22. in x 22 in. on a form
[quoted text clipped - 77 lines]
>>>>>> to be fired when the form is advanced to the next record.  I don't
>>>>>> know how to code it.  Thanks
Earl Kiosterud - 09 Jun 2007 23:53 GMT
Stephen,

Thanks.  I put the image in a separate form (so the buttons and text boxes on the first form
will be unaffected by the scrolling), and made it large as you suggested.  That does give me
scroll bars, but only because I've made the image large, but still unzoomable.  The user
needs a normal image sometimes and a zoomed image sometimes.  I've looked briefly at your
A2KLoadJpegGifVer30D.mdb.  Nice.  I can probably integrate it into this attempt in Access
and get the zoom capability.  But there's more needed.

Let me take a moment to describe the project.  It is replacing a data entry form that's
currently implemented in Excel (which I can make dance and sing with VBA, though I can't yet
with Access).  As the user goes through each record a document image is fetched and placed
onscreen. The user sometimes needs to visually extract information from the image, which is
then keyed in.  Some images are difficult to read.  The Excel program allows for zooming,
changing contrast and brightness, and rotating 90° left.  These are the image capabilities
we need.

Is there functionality available for any of rotating and changing brightness and contrast?
Signature

Earl Kiosterud
www.smokeylake.com

-----------------------------------------------------------------------

> HI Rob,
> the OP can place an Image control, sized to 22. in x 22 in. on a form sized the same. In
[quoted text clipped - 67 lines]
>>>>>> I need to have an event-fired sub put an image on a form.  It needs to be fired when
>>>>>> the form is advanced to the next record.  I don't know how to code it.  Thanks
Stephen Lebans - 11 Jun 2007 00:53 GMT
While your Image manipulation requriements could be accomplished directly in
VBA under Access it would be a complex process for a developer without a lot
of GDI experience.
An alternative would be to embedd the image as an OLE object. For example
you could embedd a blank Excel SpreadSheet. At runtime, insert the desired
Image into the Excel sheet via Automation. YOu could then use the Excel
Picture TollBar as you are currently.

Signature

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.

> Stephen,
>
[quoted text clipped - 98 lines]
>>>>>>> to be fired when the form is advanced to the next record.  I don't
>>>>>>> know how to code it.  Thanks
Earl Kiosterud - 11 Jun 2007 21:50 GMT
Stephen,

Thanks.  The embedded OLE object with Excel automation sounds workable.  I'll get to work on
it.
Signature

Earl Kiosterud
www.smokeylake.com

   Note: Some folks prefer bottom-posting.
   But if you bottom-post to a reply that's
   already top-posted, the thread gets messy.
   When in Rome...
-----------------------------------------------------------------------

> While your Image manipulation requriements could be accomplished directly in VBA under
> Access it would be a complex process for a developer without a lot of GDI experience.
[quoted text clipped - 93 lines]
>>>>>>>> I need to have an event-fired sub put an image on a form.  It needs to be fired
>>>>>>>> when the form is advanced to the next record.  I don't know how to code it.  Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.