Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help with Images in Access97 Db Please

Folks, I'm JUST starting out with VB6, and know next to nothing, so I'll have to be kinda long-winded in my request - please bear with me...

I'm attempting to create a database to store information about custom content for the game The Sims 2. I have the form made, and all of the elements in place, linked to their respective fields in the Access97 Db I've created.

What I want to do is to store the path/filename to a picture on the user's HD in one or two of the fields, and allow the user to browse for each picture as they add records into the Db. I'm using the Image box, not the Picture box. I've accomplished the part of making a button to call the commdlg32, get the picture, and display it on the form, but I can't figure out how to tell it to save just the path/filename into the field, and then subsequently display that picture(s) again when the record is accessed the next time.

I really need a code example for this - I already understand the concepts, but I can't figure out how to implement it.

Please help, Thank You in advance.

Comments

  • Wiseguy2004Wiseguy2004 Member Posts: 4
    Well, it's been a week today, so I suppose no one is going to reply - thanks for your time anyway.
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    : Well, it's been a week today, so I suppose no one is going to reply
    : - thanks for your time anyway.
    :

    Well I wish I could, but I really don't know much about Office-VB6 integration, sorry.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Wiseguy2004Wiseguy2004 Member Posts: 4
    : Well I wish I could, but I really don't know much about Office-VB6
    : integration, sorry.
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry

    It's really frustrating, as this is holding up the entire project. I've read and tried everything I can find about the Image Box, but I just can't find an example of what I need to do.

    I'll find the answer somewhere, or stumble over it while experimenting - I find a lot of answers that way, heheh.

    Thanks for replying, Richard.

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    I guess I'm also not sure about which part you need help with.
    If you can load the picture into a picturebox, don't you automatically know the path?
    I don't know how, but when loading the record you could hide the picture column and instead of it display the images in a picturebox.
    That way, the column would still be the same but the user would work with it as if it were a real picture rather than a link to a file.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • Wiseguy2004Wiseguy2004 Member Posts: 4
    : I guess I'm also not sure about which part you need help with.
    : If you can load the picture into a picturebox, don't you
    : automatically know the path?
    : I don't know how, but when loading the record you could hide the
    : picture column and instead of it display the images in a picturebox.
    : That way, the column would still be the same but the user would work
    : with it as if it were a real picture rather than a link to a file.
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry

    Okay, here's the code that I'm using:

    [code]
    Private Sub cmdAddPic1_Click()
    Dim Pic1Location As String
    cd1.ShowOpen
    Pic1Location = cd1.FileName
    If cd1.FileName = "" Then GoTo subend
    txtPic1 = Pic1Location
    imgPic1 = LoadPicture(txtPic1)
    subend:
    End Sub
    [/code]

    This is what happens: The user clicks on the "Add Picture 1" button, commdlg32 (cd1) is invoked to browse for the desired picture. The path/filename of the chosen picture is stored as Pic1Location, and copied (as a string) to the Text Box txtPic1 (originally I just used this as a test to be sure the entire path and filename were being recognized, but then I got the idea to actually USE this as a means of saving the location into the Db). Then the image is displayed in the Image Box imgPic1 using the LoadPicture method and getting the path/filename from the Text Box txtPic1

    That part works - I can browse for the picture, locate it, the path/filename is stored, the image shows up right then in the Image Box, and the test string is saved in the field of the Db. But... Then when the record is browsed to again, either no picture at all, or a picture from the previous record is shown in the Image Box.

    I've tried it with and without using the "Add Entry" button

    [code]
    Private Sub cmdAdd_Click()
    db1.Recordset.AddNew
    End Sub
    [/code]

    Also, with and without using the "Update Db" button

    [code]
    Private Sub cmdUpdate_Click()
    db1.Refresh
    End Sub
    [/code]

    But it seems to make no difference whatsoever.

    I'm just totally stumped, and I can't find any info anywhere.

    If this were just a program for my own use I'd either store the pictures IN the Db, or maybe find a way to just manually enter the path/filename each time, but I want to release this to the TS2 community, and I HAVE to make it so each user can browse their own computer for the pictures. Eventually, I hope to also find a way to enable them to save a picture they've copied to the clipboard from a webpage, and save them the extra step of having to save it manually, but that's a "whole 'nother story" heheh.

    (I've enclosed a screenshot of the program running so you can get an idea of what I'm doing)
Sign In or Register to comment.