Solved Pictures (1 Viewer)

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
Ok, I have a database with a picture associated to each record, I have a frame to contain the picture on a form and as you change record it displays the correct picture for each record (a bit like a contacts database). I wanted to make the database moveable so that it showed the records wherever it was stored. To do this I stored the filename with no path so literally I had a field with 12345.jpg, 12346.jpg etc for each record. and stored the pictures in the same directory as the database.

I then moved everything to another directory (say from c:\database to c:\project - nothing complicated in the path structure or any networking) and it has stopped working (no pictures displayed). Is there somewhere in an access database that it stores the basic path for pictures?

Any help would be greatly appreciated.
 

moke123

AWF VIP
Local time
Yesterday, 21:43
Joined
Jan 11, 2013
Messages
3,852
For example purposes say you have all your pictures in a directory name "Photos" and this directory is in the same directory as your .accdb file and your photos field is called "Pix"

In the oncurrent event of your form you would have
Code:
Me.YourImageControlName.Picture = CurrentProject.Path & "\Photos\" & Pix
change the imagecontrol name to yours

To handle a record with no picture I would use a "No Photo" image in the folder and then use
Code:
Me.YourImageControlName.Picture = CurrentProject.Path & "\Photos\" & nz(Pix,"NoPhoto.jpg")
 

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
That seems to work a treat, many thanks.
 

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
I am now being really stupid, how do I get the value from a text box into this code? The below does not work.
Code:
Me.Image202.Picture = CurrentProject.Path & "\Pictures\" & Nz([Text6].Value, "NoPhoto.jpg")
 

bastanu

AWF VIP
Local time
Yesterday, 18:43
Joined
Apr 13, 2010
Messages
1,401
Maybe Me.Image202.Picture = CurrentProject.Path & "\Pictures\" & Nz(Me.Text6, "NoPhoto.jpg")?
Cheers,
 

bastanu

AWF VIP
Local time
Yesterday, 18:43
Joined
Apr 13, 2010
Messages
1,401
Is Text6 the name of the textbox on the form (where this code is running) holding the name of the file (12345.jpg)? What error do you get?
 

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
Yes, no error at all, just doesn't work.
 

bastanu

AWF VIP
Local time
Yesterday, 18:43
Joined
Apr 13, 2010
Messages
1,401
And you have that in the Current event of the form? Can you show us a screen shot with a record that should show it and also one of your VBE window with the code?
 

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
Private Sub Form_Current()
Me.Image202.Picture = CurrentProject.Path & "\Pictures\" & Nz(Me.Text6, "NoPhoto.jpg")
End Sub

I do actually have an error on form loading now of You entered an expression that has no value.
 

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
I have attached the database and the issue is in frmPartsList loading the subform frmPartsListPic
 

Attachments

  • REPartsBooks.zip
    1.7 MB · Views: 442

bastanu

AWF VIP
Local time
Yesterday, 18:43
Joined
Apr 13, 2010
Messages
1,401
Can you try this please:
Code:
Private Sub Form_Current()
Dim sPath as string
sPath=CurrentProject.Path & "\Pictures\" & Nz(Me.Text6, "NoPhoto.jpg")
Me.Image202.Picture = sPath
End Sub
Put a break on the last line and when it gets there hover the mouse over the previous line on sPath and check if you get the correct path.
 

bastanu

AWF VIP
Local time
Yesterday, 18:43
Joined
Apr 13, 2010
Messages
1,401
Have a look at the updated file. You never mentioned you had subforms referencing each other. Why a separate subform for the pics? And they were not really linked properly.
 

Attachments

  • REPartsBooksVlad.zip
    1.2 MB · Views: 319

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
It was to enable a lot of items to be seen in the list and more detailed data to be shown separately which is what I am trying to achieve. I want to be able to look down the list, select one and see the details.
 

bastanu

AWF VIP
Local time
Yesterday, 18:43
Joined
Apr 13, 2010
Messages
1,401
Here you go , maybe this is what you wanted?
Cheers,
 

Attachments

  • REPartsBooks_Vlad2.zip
    1.4 MB · Views: 426

Tieval

Still Clueless
Local time
Today, 01:43
Joined
Jun 26, 2015
Messages
475
Many thanks Vlad, it seems just right but I will investigate fully and get my head around what you have done :)
 

Users who are viewing this thread

Top Bottom