Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    [imgPicture].Picture = [ThePath] (2002 SP2)

    I'm using code posted by hans to try to display a picture.

    It bugs out on this line, with the error '2001, the user cancelled the previous operation' (Microsoft waffle for 'Its gone wrong !')


    [imgPicture].Picture = [ThePath]


    Where ThePath is the path to the picture (have tested this and path is fine)

    actual code is :-

    <font color=red>Private Sub Field35_Click()
    '------------------- change picture here ? ------------------------

    Dim ThePath As String, Name1 As String, Name2 As String

    ThePath = "R:FACTORYTQMSAuditingPeople"

    Name1 = DLookup("[fname]", "MEMOID", "[MEMOID]=[TEXT11] AND [DISCOUNTED]<>TRUE")
    Name2 = DLookup("[sname]", "MEMOID", "[MEMOID]=[TEXT11] AND [DISCOUNTED]<>TRUE")

    ThePath = ThePath + Name1 & "_" & Name2 & ".JPG"

    Me!Text65 = ThePath


    If Not IsNull([ThePath]) Then
    [imgPicture].Picture = [ThePath]
    SysCmd acSysCmdSetStatus, "Image: '" & [ThePath] & "'."
    Else
    [imgPicture].Picture = ""
    SysCmd acSysCmdClearStatus
    End If



    End Sub</font color=red>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    In the first place, ThePath is a variable of type String, so the test on IsNull([ThePath]) doesn't make sense (a string is never Null).
    In the second place, what is Text11? A field in the table, or a control on your form?
    You can inspect the actual value of ThePath by inserting a line

    Debug.Print ThePath

    immediately above the line

    [imgPicture].Picture = ThePath

    (no need to use square brackets for a variable). when you run the code, the value of ThePath will be displayed in the Immediate window.

  3. #3
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    Hans,
    Yea the test may be wrong, but the ThePath (my variable) is fine, eg: if i take the string and past it into the Hyperlink object of the imgPicture, you can then click on the picture area, and it will load the picture.

    so the path, is correct.

    text11, is just a code for a persons name. ignore it.

    Example, thats still gives the error.

    ThePath = "R:FACTORYTQMSAuditingPeopleJoe_Bloggs.JPG"

    imgPicture.Picture = [ThePath]



    The actual picture is in the footer of the form, if that matters.

    Ahhh i see where its going wrong. In your example you made, Picfile is record in a table, whereas i'm trying to use a string. ?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    Again, you shouldn't enclose ThePath in brackets, since it's a variable, not a field or control, but it shouldn't matter.

    What kind of control is imgPicture? The type is shown in the title bar of the Properties window if the control is selected.

  5. #5
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    Hans, its an Image

    Like a good Woody User, i've used search and I've basically got hold of your demo that you uploaded.

    The differences are, that in your demo, you created the path for the image from a table.

    My path is semi fixed, except for the name of the person, which is what that extra bit of code does.

    I have tried it without the brackets, and lots of other combinations. (some shown as comments)




    <font color=blue>Dim ThePath As String, Name1 As String, Name2 As String

    ThePath = "R:FACTORYTQMSAuditingPeople"

    Name1 = DLookup("[fname]", "MEMOID", "[MEMOID]=[TEXT11] AND [DISCOUNTED]<>TRUE")
    Name2 = DLookup("[sname]", "MEMOID", "[MEMOID]=[TEXT11] AND [DISCOUNTED]<>TRUE")

    ThePath = ThePath + Name1 & "_" & Name2 & ".JPG"

    Me!Text65 = ThePath
    imgPicture.Picture = ThePath

    'imgPicture.Picture = "'" & ThePath & "'"
    'imgPicture.Picture = chr(34) & ThePath & chr(34)


    End Sub</font color=blue>

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    I'm afraid we won't be able to solve this without seeing the database. Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  7. #7
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    Unfortunately hans, the db is huge, and tables are linked to other db's. It would take me days to cut it down. [img]/forums/images/smilies/sad.gif[/img]

    I have however made it work (kind of)

    There is a listbox on the left, List34, and another Listbox List35, on the right. , when you select items in list 35, it shows items in List34.

    List34 is based on a query. and i've made the the path string up in the query, and called it [Picfile]

    Here is the weird thing...

    When you select peoples names from the listbox on the right, the items on the left hand listbox will update. but not the image.

    but... as soon as you select an item in the left listbox the picture will update. (with the code imgPicture.Picture = [Picfile]) in the 'onupdate' event of the left listbox... i tried putting this code in all sorts of other places with no joy.

    But of course, ideally, i want the picture to update when i select someone from the people listbox on the right. but no matter what that wont work


    Here is another strange thing...

    If i make a button with this code on the form, select someone from the listbox on the right, THEN click the button with the same code, the picture will update.

    so... being sneaky... i tried using the onclick event of the right hand people list box, and using this code :-

    <font color=red>Command71.SetFocus
    SendKeys "{ENTER}", False</font color=red>

    So that whenever i click a new person in the right hand listbox, it would force the button to work....

    But..!!!! when i tried this, it gave the same old error message 'error 2001, you cancelled the previous action' (really helpfull error message that)

    I realise this probably doesn't help much... but i am still trying, and will post the answer if i manage to figure out what is going on.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    If I understand correctly, selecting an item in List35 will populate List34. Unless you take care of it in your code, no item will be selected in List34 after it has been (re)populated. So if the path/filename for your picture depends on the selected item in List34, it is undetermined at that moment.

  9. #9
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    Err typo in that i had it the wrong way round... anyways...

    if you look at the picture here... it explains a bit....

    I've just clicked my name 'Steve Wilders' in listbox 34. It has updated list 35, with the areas i am assigned to, and it has updated a temporary text field at the bottom. 'text74' with the correct path on the hdd with my photograph.
    however, as you can see, the picture has not displayed in the imgPicture box in the lower right. (dark area)

    picfile is just a specific folder on the hard drive, plus the persons name. then a .JPG.

    Ok, so i've just clicked on my name, in list 34. if i now click on button 'updates picture' my picture will show. !!

    but, if i try to put the same code (imgPicture.picture = [Picfile]), on say the click event of list34, i will get the dreaded 2001 error 'you cancelled the previous event'

    I've also tried putting the code in all sorts of other places, but it doesn't work.... the only place where i have found it to work, is if i place the code, in the afterupdate event of list35. and then, it will only work if i actually Select something from list 35

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    What happens if you change

    imgPicture.picture = [Picfile]

    to

    imgPicture.picture = Me.Text74

    or if you rename Text74 to PicFile instead?

  11. #11
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    If i put

    imgPicture.Picture = Me!Text74


    into the Onclick event of List34, then i get the 2001 error.


    I renamed Text74 to Picfile, and it just works the same, it shows the correct path.

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    I'm afraid I have no further ideas without seeing the database. (Perhaps instead of trying to cut down the existing database(s) in size, you could create a new database and import just the form plus the tables/queries needed)

  13. #13
    3 Star Lounger
    Join Date
    Sep 2002
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    I could probably do that hans.. but what about security,, ie: the db is tied to a .mdw file

    If i make another database, will you be able to view the file ?

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    You'll have to make sure that the database objects are viewable by someone without the secured .mdw file.

  15. #15
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: [imgPicture].Picture = [ThePath] (2002 SP2)

    In your attachment in <post#=495229>post 495229</post#> , in the textbox texT74 the path to the picture is wrong.
    There should be a slash just after the drive letter and colon :

    R:/Factory...
    and not :
    R:Factory...

    Could this be your problem ?
    Francois

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •