Add pictures on form using Access 2007

A

Ac

Hi,

I read some articles about the Access 2007; it said the Access 2007 will
provide the ability that the pictures can be displayed in the Continuous
Forms based on the record. However, After I added pictures in the Continuous
Form, and view at Form View, the pictures did not show as it should be, only
one picture is displayed to all records, it just as the way in Access 2003.
What did I do wrong? Below are the steps:


1. Created a table (Main) with one field named Path as text data type
2. On the data sheet view added few records, the contains of the Path like
C:\Data\Pic\Test1.JPG, C:\Data\Pic\Test2.JPG,… for each record
3. Created a Form using the table Main, and added a image named imgPic on
the Form
4. Added the following code to the form

Private Sub Form_Current()

Me![imgPic].Picture = Me![Path]
End Sub

Private Sub Path_AfterUpdate()

Me![imgPic].Picture = Me![Path]
End Sub

5. View the form on the For View

I will appreciate your advise!
 
A

Allen Browne

You don't need the code.

Just put an image control on your form.
Set its Control Source property to:
=[Path]
where Path is the name of the field that contains the fully qualified file
name.
 
A

Ac

Thanks Allen, it works well.



Allen Browne said:
You don't need the code.

Just put an image control on your form.
Set its Control Source property to:
=[Path]
where Path is the name of the field that contains the fully qualified file
name.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ac said:
Hi,

I read some articles about the Access 2007; it said the Access 2007 will
provide the ability that the pictures can be displayed in the Continuous
Forms based on the record. However, After I added pictures in the
Continuous
Form, and view at Form View, the pictures did not show as it should be,
only
one picture is displayed to all records, it just as the way in Access
2003.
What did I do wrong? Below are the steps:


1. Created a table (Main) with one field named Path as text data type
2. On the data sheet view added few records, the contains of the Path like
C:\Data\Pic\Test1.JPG, C:\Data\Pic\Test2.JPG,… for each record
3. Created a Form using the table Main, and added a image named imgPic on
the Form
4. Added the following code to the form

Private Sub Form_Current()

Me![imgPic].Picture = Me![Path]
End Sub

Private Sub Path_AfterUpdate()

Me![imgPic].Picture = Me![Path]
End Sub

5. View the form on the For View

I will appreciate your advise!
 

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