Graphic source in code?? 
Author Message
 Graphic source in code??

Can you specify the location of a graphic on a report in
the code behind the report?
Can you make that location be a RELATIVE location to the
database?
How?

McLean Jones



Wed, 23 Feb 2005 03:32:12 GMT  
 Graphic source in code??
You could probably write some code to identify the path to the current
database and then append a subfolder to it to make a "relative" path to your
pictures.

=================================================

Use an unbound image frame named: ImageFrame
and add a field to your table called ImagePath.

To add the picture to a report just use code like this in the On Format
event of the Detail Section.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
   Me![ImageFrame].Picture = Me![ImagePath]
End Sub

In the OnCurrent event  of the form use this code:

Private Sub Form_Current()
On Error GoTo Err_Form_Current

  If IsNull(Me![ImagePath]) Then
    Me![ImageFrame].Picture = "c:\msaccess.jpg"
  Else
    Me![ImageFrame].Picture = Me![ImagePath]
  End If

Exit_Form_Current:
  Exit Sub

Err_Form_Current:
  Select Case Err.Number
    Case 2220
      'ignore the Can't Load Image error
    Case Else
      MsgBox ("Error # " & Str(Err.Number) & " was generated by " &
Err.Source & Chr(13) & Err.Description)
      Resume Exit_Form_Current
  End Select

End Sub

The image takes a second or two to load. A dialog is put on screen too.
This process can get very annoying after a while because it happens every
time the user navigates to another record.

From Tony Toews' web site: http://www.granite.ab.ca/access/imagehandling.htm
Getting tired of seeing that Loading Image dialogue flicker?  Getting errors
by users who click on things before this is finished displaying? Try
creating/changing the following registry key
HKEY_LOCAL_MACHINE\Software\Microsoft\Shared
Tools\GraphicsFilters\Import\JPEG\Options
ShowProgressDialog to No

I use the Tab control to "hide" the image on a different "page".
I also move the code to the OnGotFocus event of the ImagePath text box
which is on the next page of the Tab control.
This way, the only time the picture loads is when the user clicks the tab to
see it.

--
Joe Fallon
Access MVP


Quote:
> Can you specify the location of a graphic on a report in
> the code behind the report?
> Can you make that location be a RELATIVE location to the
> database?
> How?

> McLean Jones



Wed, 23 Feb 2005 11:43:44 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Visual Basic source-code to C++ source-code

2. Visual Basic source-code to C++ source-code

3. Visual Basic source-code to C++ source-code

4. A great source-code-source

5. Code 128c Barcode generator source code

6. Extracting Source Code from a Code Module

7. Source code - Postal Code

8. FREE VB Classes with source code and demo code

9. Source code project - producing code documentation

10. VB source for school grading program with graphics

11. Source Graphic for BitBlt

12. Need Source for graphics/images on toolbar buttons?

 

 
Powered by phpBB® Forum Software