Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Images

Status
Not open for further replies.

Hookstrat

Technical User
Jun 11, 2002
43
US
Sorry for re-posting, but I wasn't sure if my adding to my old thread would get a response. I have been working on this database for a long time and if I can just get these maps to display correctly I can put this beast to rest. I'm still having trouble getting linked images to sidplay in a form. I have a table with two fields... [Map] which contains linked maps from the directory "c:\mydocuments\sanitarymaps" and [ID] which is just an autonumbered field. All of my maps are saved as the corresponding records autonumber. So the map for the first record is simply "1.jpg". I have a bound image control named Map and I set the form's properties as "Picture - (none)" and "Picture Type - Linked". Then I put this code into the On_Current Event of the form.
Code:
Private Sub Form_Current()
If Me![ID] <> 0 Then
           
        Me!Map.Picture = &quot;c:\MyDocuments\SanitaryMaps\&quot; & Me![ID] & &quot;.jpg&quot;
    End If

End Sub
[\code]
Unfortunately the debugger keeps saying: Run-time error &quot;438&quot; - Object doesn't support this property or method.  How can I get Access to automatically display the correct picture in my form??  If someone can tell me what I am doing wrong I would really appreciate the help.  Thanks in advance for any suggestions.                L.H.
 
I wonder, do you have a Picture frame named Map? It looks like you are update such an object instead of the form. If is the form property your code should be Me.Picture or Me!Picture (I never use Me! I use frmName.Picture) I would recomend though to use a Picture frame named Pic1 in a corner of your form.
In the form itself I'm not sure if the picture will cover all the available space.
You can also try this in steps,
frmName.Picture = &quot;c:\MyDocuments\SanitaryMaps\1.jpg&quot;
then add the other field if this works
fmrName.Picture = &quot;c:\MyDocuments\SanitaryMaps\&quot; & frmName.ID & &quot;.jpg&quot;

Hope you get the idea you need,
HAH
 
Hey,

I know for sure that the code works. I just added a new table and this code to my db. I have over 500 pictures and they are all showing up great. the only problem is that the pictures sometimes doensn't refresh right. HAH is probably right, you should check your names on the form and the table.

On the properties window, go to Other, then check the name there. Also I often don't use Me, like HAH, and it turns out i didn't in this case either. So that might be the clincher, the me!....
 
Thanks for the suggestion HAH, I've been messing around with these 5 lines of code all day. One version of my code looks like this:
Code:
Private Sub Form_Current()
If Me![ID] <> 0 Then
           
    Form_FrmLinkedMap.Picture = &quot;c:\MyDocuments\SanitaryMaps\&quot; & Form_FrmLinkedMap.ID & &quot;.jpg&quot;

    End If

End Sub
[\code]

With this I am getting &quot;compile error: method or data member not found&quot; and the debugger is pointing to the &quot;.ID&quot; in the &quot;Form_FrmLinkedMap.ID&quot; part of the code.  I also tried doing it in steps.

[code]
Private Sub Form_Current()
If Me![ID] <> 0 Then
     Form_FrmLinkedMap.Picture = &quot;c:\MyDocuments\SanitaryMaps\1.jpg&quot;
 
    End If

End Sub 
[\code]

With this code Access 2000 gives me a runtime error &quot;2220&quot;- Unable to load &quot;c:\MyDocuments\SanitaryMaps\1.jpg&quot;.  I forgot to note that my .jpegs were created with ACDsee...does ACDsee not work through Access??  Please help me!                            Most appreciatively,
                                   L.H.
 
Thanks for the suggestion HAH, I've been messing around with these 5 lines of code all day. One version of my code looks like this:
Code:
Private Sub Form_Current()
If Me![ID] <> 0 Then
           
    Form_FrmLinkedMap.Picture = &quot;c:\MyDocuments\SanitaryMaps\&quot; & Form_FrmLinkedMap.ID & &quot;.jpg&quot;

    End If

End Sub
[\code]

With this I am getting &quot;compile error: method or data member not found&quot; and the debugger is pointing to the &quot;.ID&quot; in the &quot;Form_FrmLinkedMap.ID&quot; part of the code.  I also tried doing it in steps.

[code]
Private Sub Form_Current()
If Me![ID] <> 0 Then
     Form_FrmLinkedMap.Picture = &quot;c:\MyDocuments\SanitaryMaps\1.jpg&quot;
 
    End If

End Sub 
[\code]

With this code Access 2000 gives me a runtime error &quot;2220&quot;- Unable to load &quot;c:\MyDocuments\SanitaryMaps\1.jpg&quot;.  It is still just displaying showing up as an icon link.  I forgot to note that my .jpegs were created with ACDsee...does ACDsee not work through Access??  Please help me!                            Most appreciatively,
                                   L.H.
 
Hey,

In one instance you refer to .jpegs and the other instance you refer to .jpg Now we are all aware that the files are jpeg, however you might want to check how the file extension on your picture is saved, i.e. jpeg, or jpg. You will get that error if the link isn't connecting, much the same as a bad hyperlink on a website: address not found.

I get that message when I didn't put in the correct file name.
 
I agree with markphsd, looks like the extencion of your files may be wrong. Also make sure that the path is 100% correct with no error, typos, or the slash pointing in the wrong direction. MS is special on giving error that have nothing to do with what is going on.
The name of you form look kind or weird, look on the database manager window on the Form tab and make sure your name is correct to. When I work for a long time on a piece of code and so focus on other things that the small ones kick me on the face. I believe you are very close to resolve this, lets see if by COB today you can have it done.

HAH
 
Well you were all correct in your assumptions! I came back to the code this morning and noticed my error in less than 30 seconds. I needed a space between &quot;My Documents&quot;. I guess whoever said &quot;don't sweat the small stuff&quot; wasn't a programmer. I did end up using Me!, however, as the line refering to my ID field kept giving my a compiling error when I just tried to use &quot;Form_Name.ID&quot;. So even though my code might not be the best way, I'm just grateful that I got it to work! Is there any efficiency differences between the two options?? Here is my final code if anyone cares.
Code:
Private Sub Form_Current()
If Me![ID] <> 0 Then
     
     Me.Picture = &quot;c:\My Documents\SanitaryMaps\&quot; & Me![ID] & &quot;.jpg&quot;

    End If

End Sub
[\code]

Thanks again for all of the help guys!    
L.H.
 
L.H -
Glad that you got it to work!. The use of the form name rather that ME makes it easy for other people to read when you have multimple call to multiple objects all over the place. Also, when you refer to objects in your form you don't even have to use the ME! as the form will know that the object you are refering to is on the form. Of course for the form properties it has to be used.
Access is like a woman, you have to give it what it wants so it can work with you!.
Now you &quot;can put this beast to rest...&quot;. Glad to be of some help.

HAH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top