Solved Retrieve Image.Picture path (1 Viewer)

Babycat

Member
Local time
Today, 06:26
Joined
Mar 31, 2020
Messages
275
Hi Everyone.

I am using unbound image (linked type) to display a product photo.
To display, I set it to photo path such as:
Code:
Image.Picture = "C:\Users\Admin\Desktop\1.jpg"

But when I try to read the path back:
Code:
Pathstr = Image.Picture
I always get result: Pathstr = "(none)"

How can I get the correct photo path?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:26
Joined
Oct 29, 2018
Messages
21,469
Hi. That code works for me. Can you post a sample db for testing?
 

Babycat

Member
Local time
Today, 06:26
Joined
Mar 31, 2020
Messages
275
Hi. That code works for me. Can you post a sample db for testing?

Hi. Sorry, I was looking on wrong form/code.

Actually I set the photo path in Control Source as below picture (I did not set Image.Picture = "C:\Users\Admin\Desktop\1.jpg")
Now I want to read back the control source by VBA but I dont know which property to read, so i try to read at Image.Piture
Code:
Pathstr = Image.Picture
However it returns "(none)"

Is there anyway to get control source string with VBA?

1639503624481.png
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:26
Joined
Sep 21, 2011
Messages
14,286
OldValue gives me my path from the ControlSource?
Also Properties(3) gives the same value?
 
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:26
Joined
Oct 29, 2018
Messages
21,469
Is there anyway to get control source string with VBA?
What about ControlSource?
Code:
Pathstr = Me.Image.ControlSource
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:26
Joined
Sep 21, 2011
Messages
14,286
When I went looking for that, it never came up in intellisense?
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:26
Joined
Oct 29, 2018
Messages
21,469
When I went looking for that, it never came up in intellisense?
Sorry if that didn't work. I didn't get a chance to test it first. I just tried to assign a path to the Control Source property as shown in the above image, but the picture didn't show up when I viewed the form. Perhaps you can't assign an image that way, I know I haven't tried to do it that way before. I either use the Picture property or assign a field name to the Control Source property.
 

Babycat

Member
Local time
Today, 06:26
Joined
Mar 31, 2020
Messages
275
Sorry if that didn't work. I didn't get a chance to test it first. I just tried to assign a path to the Control Source property as shown in the above image, but the picture didn't show up when I viewed the form. Perhaps you can't assign an image that way, I know I haven't tried to do it that way before. I either use the Picture property or assign a field name to the Control Source property.
Hi DB

I have just found something, if you set control source as above code, the image does not show up when form open.
But when you input into control source an expression:

="C:\Users\Admin\Desktop\" & "1.jpg"

It shows up
 

Attachments

  • sample.zip
    527.6 KB · Views: 242

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:26
Joined
Oct 29, 2018
Messages
21,469
Hi DB

I have just found something, if you set control source as above code, the image does not show up when form open.
But when you input into control source an expression:

="C:\Users\Admin\Desktop\" & "1.jpg"

It shows up
I tried that, but the image still didn't show up for me. However, this returned the info (as entered) when I tried it.
Code:
 PathStr = Me.Image.Properties("ControlSource")
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:26
Joined
Oct 29, 2018
Messages
21,469
I tried that, but the image still didn't show up for me. However, this returned the info (as entered) when I tried it.
Code:
PathStr = Me.Image.Properties("ControlSource")
Belay that. I had a typo, and the image shows up fine now, even without doing the concatenation trick.
 

Users who are viewing this thread

Top Bottom