Display a picture without storing them in the table-HELP!!!

S

SoniaC

I am trying to display a picture in a form without storing the pictures in
the table.

I followed the instructions in the help file for this procedure that come in
the help access but something is not working. The ImagePath Text field will
change from record to record when I select the record at the combo box
linked to the form, but the picture is not changing at all.

I did everything following the help file as follow:

"To display pictures that change from record to record without storing them
in a table, create a text field to store the locations of the image files.
You must store the locations of the pictures in a text field if you want to
display the pictures in a data access page. You can also use a text field to
store the location of pictures and then use those pictures in a form or
report, but you must use Visual Basic event procedures to display the
pictures. "

Then I add the event procedure as follow, where ImageControlName is Image13
and ImagePath is ImagePath and the path to the picture is the path for the
first record in the list (F:\Converted Files\10301.JPG), then:
1.. If the field list isn't displayed, click Field List on the toolbar.
2.. From the field list, drag the field that contains the locations of the
pictures to the form or report.
3.. In the toolbox, click the Image tool .
4.. On the form or report, click where you want to place the object.
5.. In the Insert Picture dialog box, specify the path to any picture, and
then click OK. For example, you can type the path to the picture for the
first record.
6.. Double-click the form selector or the report selector to open the
property sheet.
7.. Click the Build button next to the OnCurrent property box, and then
click Code Builder in the Choose Builder dialog box.
8.. Create the following event procedure. Substitute the name of the image
control on your form or report for ImageControlName and the name of the
control containing the path for ImagePath.
Private Sub Form_Current()On Error Resume NextMe![ImageControlName].Picture
= Me![ImagePath]End Sub9.. On the File menu in the Visual Basic Editor,
click Close and return to Microsoft Access.
10.. Click the control that is bound to the text field containing the
location of the pictures, and then click Properties on the toolbar to open
the property sheet..
11.. Click the Build button next to the AfterUpdate property box, click
Code Builder in the Choose Builder dialog box, and create the following
event procedure. Substitute the name of the image control on your form or
report for ImageControlName and the name of the control containing the path
for ImagePath.
Private Sub ImagePath_AfterUpdate()On Error Resume
NextMe![ImageControlName].Picture = Me![ImagePath]End SubThis event
procedure enables you to add or change a picture location in Form view.

12.. On the File menu in the Visual Basic Editor, click Close and return
to Microsoft Access.

Please help.
 
J

Joe Fallon

If you are interested in storing the picture in the database check out
Stephen Lebans' web site:
http://www.lebans.com/loadsavejpeg.htm

The approved solution is to store the path and display the picture
dynamically.
How to Link a Picture to a Form:

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



SoniaC said:
I am trying to display a picture in a form without storing the pictures in
the table.

I followed the instructions in the help file for this procedure that come in
the help access but something is not working. The ImagePath Text field will
change from record to record when I select the record at the combo box
linked to the form, but the picture is not changing at all.

I did everything following the help file as follow:

"To display pictures that change from record to record without storing them
in a table, create a text field to store the locations of the image files.
You must store the locations of the pictures in a text field if you want to
display the pictures in a data access page. You can also use a text field to
store the location of pictures and then use those pictures in a form or
report, but you must use Visual Basic event procedures to display the
pictures. "

Then I add the event procedure as follow, where ImageControlName is Image13
and ImagePath is ImagePath and the path to the picture is the path for the
first record in the list (F:\Converted Files\10301.JPG), then:
1.. If the field list isn't displayed, click Field List on the toolbar.
2.. From the field list, drag the field that contains the locations of the
pictures to the form or report.
3.. In the toolbox, click the Image tool .
4.. On the form or report, click where you want to place the object.
5.. In the Insert Picture dialog box, specify the path to any picture, and
then click OK. For example, you can type the path to the picture for the
first record.
6.. Double-click the form selector or the report selector to open the
property sheet.
7.. Click the Build button next to the OnCurrent property box, and then
click Code Builder in the Choose Builder dialog box.
8.. Create the following event procedure. Substitute the name of the image
control on your form or report for ImageControlName and the name of the
control containing the path for ImagePath.
Private Sub Form_Current()On Error Resume NextMe![ImageControlName].Picture
= Me![ImagePath]End Sub9.. On the File menu in the Visual Basic Editor,
click Close and return to Microsoft Access.
10.. Click the control that is bound to the text field containing the
location of the pictures, and then click Properties on the toolbar to open
the property sheet..
11.. Click the Build button next to the AfterUpdate property box, click
Code Builder in the Choose Builder dialog box, and create the following
event procedure. Substitute the name of the image control on your form or
report for ImageControlName and the name of the control containing the path
for ImagePath.
Private Sub ImagePath_AfterUpdate()On Error Resume
NextMe![ImageControlName].Picture = Me![ImagePath]End SubThis event
procedure enables you to add or change a picture location in Form view.

12.. On the File menu in the Visual Basic Editor, click Close and return
to Microsoft Access.

Please help.
 
J

John Nurick

Hi Sonia,

You may find it easier to download Arvin Meyer's "PictureMgr" sample
database from here http://www.datastrat.com/DataStrat2.html

It shows the techniques for managing pictures as external
files.

I am trying to display a picture in a form without storing the pictures in
the table.

I followed the instructions in the help file for this procedure that come in
the help access but something is not working. The ImagePath Text field will
change from record to record when I select the record at the combo box
linked to the form, but the picture is not changing at all.

I did everything following the help file as follow:

"To display pictures that change from record to record without storing them
in a table, create a text field to store the locations of the image files.
You must store the locations of the pictures in a text field if you want to
display the pictures in a data access page. You can also use a text field to
store the location of pictures and then use those pictures in a form or
report, but you must use Visual Basic event procedures to display the
pictures. "

Then I add the event procedure as follow, where ImageControlName is Image13
and ImagePath is ImagePath and the path to the picture is the path for the
first record in the list (F:\Converted Files\10301.JPG), then:
1.. If the field list isn't displayed, click Field List on the toolbar.
2.. From the field list, drag the field that contains the locations of the
pictures to the form or report.
3.. In the toolbox, click the Image tool .
4.. On the form or report, click where you want to place the object.
5.. In the Insert Picture dialog box, specify the path to any picture, and
then click OK. For example, you can type the path to the picture for the
first record.
6.. Double-click the form selector or the report selector to open the
property sheet.
7.. Click the Build button next to the OnCurrent property box, and then
click Code Builder in the Choose Builder dialog box.
8.. Create the following event procedure. Substitute the name of the image
control on your form or report for ImageControlName and the name of the
control containing the path for ImagePath.
Private Sub Form_Current()On Error Resume NextMe![ImageControlName].Picture
= Me![ImagePath]End Sub9.. On the File menu in the Visual Basic Editor,
click Close and return to Microsoft Access.
10.. Click the control that is bound to the text field containing the
location of the pictures, and then click Properties on the toolbar to open
the property sheet..
11.. Click the Build button next to the AfterUpdate property box, click
Code Builder in the Choose Builder dialog box, and create the following
event procedure. Substitute the name of the image control on your form or
report for ImageControlName and the name of the control containing the path
for ImagePath.
Private Sub ImagePath_AfterUpdate()On Error Resume
NextMe![ImageControlName].Picture = Me![ImagePath]End SubThis event
procedure enables you to add or change a picture location in Form view.

12.. On the File menu in the Visual Basic Editor, click Close and return
to Microsoft Access.

Please help.
 
S

SoniaC

Thank you Joe and John for your help.
It is working now
Thanks again.

Sonia







John Nurick said:
Hi Sonia,

You may find it easier to download Arvin Meyer's "PictureMgr" sample
database from here http://www.datastrat.com/DataStrat2.html

It shows the techniques for managing pictures as external
files.

I am trying to display a picture in a form without storing the pictures in
the table.

I followed the instructions in the help file for this procedure that come in
the help access but something is not working. The ImagePath Text field will
change from record to record when I select the record at the combo box
linked to the form, but the picture is not changing at all.

I did everything following the help file as follow:

"To display pictures that change from record to record without storing them
in a table, create a text field to store the locations of the image files.
You must store the locations of the pictures in a text field if you want to
display the pictures in a data access page. You can also use a text field to
store the location of pictures and then use those pictures in a form or
report, but you must use Visual Basic event procedures to display the
pictures. "

Then I add the event procedure as follow, where ImageControlName is Image13
and ImagePath is ImagePath and the path to the picture is the path for the
first record in the list (F:\Converted Files\10301.JPG), then:
1.. If the field list isn't displayed, click Field List on the toolbar.
2.. From the field list, drag the field that contains the locations of the
pictures to the form or report.
3.. In the toolbox, click the Image tool .
4.. On the form or report, click where you want to place the object.
5.. In the Insert Picture dialog box, specify the path to any picture, and
then click OK. For example, you can type the path to the picture for the
first record.
6.. Double-click the form selector or the report selector to open the
property sheet.
7.. Click the Build button next to the OnCurrent property box, and then
click Code Builder in the Choose Builder dialog box.
8.. Create the following event procedure. Substitute the name of the image
control on your form or report for ImageControlName and the name of the
control containing the path for ImagePath.
Private Sub Form_Current()On Error Resume NextMe![ImageControlName].Picture
= Me![ImagePath]End Sub9.. On the File menu in the Visual Basic Editor,
click Close and return to Microsoft Access.
10.. Click the control that is bound to the text field containing the
location of the pictures, and then click Properties on the toolbar to open
the property sheet..
11.. Click the Build button next to the AfterUpdate property box, click
Code Builder in the Choose Builder dialog box, and create the following
event procedure. Substitute the name of the image control on your form or
report for ImageControlName and the name of the control containing the path
for ImagePath.
Private Sub ImagePath_AfterUpdate()On Error Resume
NextMe![ImageControlName].Picture = Me![ImagePath]End SubThis event
procedure enables you to add or change a picture location in Form view.

12.. On the File menu in the Visual Basic Editor, click Close and return
to Microsoft Access.

Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top