All
I have a problem with a picturebox in Access 2007.
I created a table tblJPG with two fields:
Counter: an automatic incremental number which is the Primary Key
Text: some text about the picture
The effective pictures are stored in a folder JPG which is a subfolder of the location where the main access database is stored.
I created a form. The recordsource of the form is tblJPG so it shows each "counter" and "text" field stored in the table tblJPG. Until now, everything is fine.
I also put an image control on the form named imgJPG. The JPG's are named after their Primary Key. So record 1 is related with 1.jpg, record 2 is related with 2.jpg, ...
On the form, I use next code
txtCounter is a text field with the value of Counter of table tblJPG (so the primary key).
Access is not showing the pictures as expected. For some reason, access shows another picture. For example: if txtCounter got the value 16, Access shows the image 1.jpg (although 16.jpg does exists and is not a corrupt file). Sometimes the correct picture is shown, and other times the wrong file is shown although strY refers to the correct file.
When I create an extra (temporary) picturebox and I set the property "Picture" in the property sheet to "16.jpg", the correct file is shown.
Does somebody got an idea why this is happening and how to solve this?
Regards
Ino
I have a problem with a picturebox in Access 2007.
I created a table tblJPG with two fields:
Counter: an automatic incremental number which is the Primary Key
Text: some text about the picture
The effective pictures are stored in a folder JPG which is a subfolder of the location where the main access database is stored.
I created a form. The recordsource of the form is tblJPG so it shows each "counter" and "text" field stored in the table tblJPG. Until now, everything is fine.
I also put an image control on the form named imgJPG. The JPG's are named after their Primary Key. So record 1 is related with 1.jpg, record 2 is related with 2.jpg, ...
On the form, I use next code
Code:
[INDENT]Private Sub Form_Current()
Dim strY As String
strY = CurrentProject.Path & "\jpg\" & txtCounter & ".jpg"
Debug.Print strY
Me.imgJPG.Picture = strY
End Sub
[/INDENT]
Access is not showing the pictures as expected. For some reason, access shows another picture. For example: if txtCounter got the value 16, Access shows the image 1.jpg (although 16.jpg does exists and is not a corrupt file). Sometimes the correct picture is shown, and other times the wrong file is shown although strY refers to the correct file.
When I create an extra (temporary) picturebox and I set the property "Picture" in the property sheet to "16.jpg", the correct file is shown.
Does somebody got an idea why this is happening and how to solve this?
Regards
Ino
Last edited: