Results 1 to 28 of 28

Thread: [RESOLVED] how to add & save pic to access with vb 6

  1. #1

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Resolved [RESOLVED] how to add & save pic to access with vb 6

    hello
    i did a project in vb 6 with customers
    and i cannot figure out how to add & save picture to access.
    i search the web but no luck
    hope you pro guys can help me
    this is the code for the saving customers.
    ****************************************

    Dim NewID As Long
    NewID = NextID("ID", "Customers")
    CN.Execute "INSERT INTO Customers (ID, FullName, Address, DateBirth, Facebook, Email, Phone, Cellular, HairColour, Oxygen) VALUES (" & _
    NewID & ", '" & _
    RplS(Txt(1).Text) & "', '" & _
    RplS(Txt(2).Text) & "', #" & _
    MyDate(PckBirth.Value) & "#, '" & _
    RplS(Txt(4).Text) & "', '" & _
    RplS(Txt(5).Text) & "', '" & _
    RplS(Txt(6).Text) & "', '" & _
    RplS(Txt(7).Text) & "', '" & _
    RplS(Txt(8).Text) & "', '" & _
    CmbOxygen.Text & "')"

    Set Itm = LsVw.ListItems.Add(, , Txt(1).Text)
    Itm.Tag = NewID
    Itm.Bold = True
    Itm.SubItems(1) = Txt(2).Text
    Itm.SubItems(2) = Format(PckBirth.Value, "dd/mm/yyyy")
    Itm.SubItems(3) = Txt(4).Text
    Itm.SubItems(4) = Txt(5).Text
    Itm.SubItems(5) = Txt(6).Text
    Itm.SubItems(6) = Txt(7).Text
    Itm.SubItems(7) = Txt(8).Text
    Itm.SubItems(8) = CmbOxygen.Text
    Itm.EnsureVisible
    Itm.Selected = True
    StBar.Panels(2) = Format(LsVw.ListItems.Count, "#,###0")

    If ChkRepeat.Value Then
    ClearDetails
    Txt(1).SetFocus
    Exit Sub
    End If
    TmrClose.Enabled = True
    *******************************
    im using a toolbar for this
    tnx in advanced
    Last edited by salsa31; Jan 2nd, 2012 at 10:36 AM.

  2. #2
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: hot to add & save pic to access with vb 6

    Salsa

    My suggestion would be to add the filename and full path
    as text fields in lieu of trying to add a BMP to a field.

    Then, add some code to retrieve the BMP and put it
    where you want it on your form.

    Spoo

  3. #3

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: hot to add & save pic to access with vb 6

    Quote Originally Posted by Spoo View Post
    Salsa

    My suggestion would be to add the filename and full path
    as text fields in lieu of trying to add a BMP to a field.

    Spoo
    i tryed
    Last edited by salsa31; Jan 3rd, 2012 at 02:31 AM.

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: how to add & save pic to access with vb 6

    There is an example in the Database FAQs you may want to look at

    Note that Spoo's suggestion would mean you wouldn't actually save the image, but the path/filename to the image. This has problems if your database is used on other PCs or someone deletes/renames the image. You do have options depending on your needs
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    hello lavolpe
    tnx for the example
    i somehow mange to enter a pic
    but when i edit & update it 2 things happen.

    1.all of the cust has the same pic

    2.suddenly the pic of the cust disappears
    this is the code for save:
    *****************************
    Dim NewID As Long
    NewID = NextID("ID", "Customers")
    CN.Execute "INSERT INTO Customers (ID, FullName, Address, DateBirth, Facebook, Email, Phone, Cellular, HairColour, Oxygen, Photo) VALUES (" & _
    NewID & ", '" & _
    RplS(Txt(1).Text) & "', '" & _
    RplS(Txt(2).Text) & "', #" & _
    MyDate(PckBirth.Value) & "#, '" & _
    RplS(Txt(4).Text) & "', '" & _
    RplS(Txt(5).Text) & "', '" & _
    RplS(Txt(6).Text) & "', '" & _
    RplS(Txt(7).Text) & "', '" & _
    RplS(Txt(8).Text) & "', '" & _
    CmbOxygen.Text & "', '" & _
    CmmDlg.FileName & "')"



    Set Itm = LsVw.ListItems.Add(, , Txt(1).Text)
    Itm.Tag = NewID
    Itm.Bold = True
    Itm.SubItems(1) = Txt(2).Text
    Itm.SubItems(2) = Format(PckBirth.Value, "dd/mm/yyyy")
    Itm.SubItems(3) = Txt(4).Text
    Itm.SubItems(4) = Txt(5).Text
    Itm.SubItems(5) = Txt(6).Text
    Itm.SubItems(6) = Txt(7).Text
    Itm.SubItems(7) = Txt(8).Text
    Itm.SubItems(8) = CmbOxygen.Text
    Itm.EnsureVisible
    Itm.Selected = True
    StBar.Panels(2) = Format(LsVw.ListItems.Count, "#,###0")

    If ChkRepeat.Value Then
    ClearDetails
    Txt(1).SetFocus
    Exit Sub
    End If
    TmrClose.Enabled = True
    this is the code for edit:
    ***********************
    If LsVw.SelectedItem Is Nothing Then Exit Sub
    Me.Enabled = False
    LsVw.SelectedItem.EnsureVisible
    LsVw.SelectedItem.Selected = True
    LsVw.Enabled = False
    LsVw.BackColor = &H8000000F
    FrCust.Caption = LsVw.SelectedItem & ""
    BttnPhoto.Caption = ""
    ChkRepeat.Enabled = False
    TmrOpen.Enabled = True
    SubBttns
    With LsVw.SelectedItem
    Txt(1).Text = .Text
    Txt(2).Text = .SubItems(1)
    PckBirth.Value = .SubItems(2)
    Txt(4).Text = .SubItems(3)
    Txt(5).Text = .SubItems(4)
    Txt(6).Text = Replace$(.SubItems(5), " - ", "")
    Txt(7).Text = Replace$(.SubItems(6), " - ", "")
    Txt(8).Text = .SubItems(7)
    CmbOxygen.Text = .SubItems(8)
    End With
    Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    End Sub
    and this is the code for update:
    ************************

    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "', " & _
    "Photo= '" & CustPhoto & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag

    With LsVw.SelectedItem
    .Text = Txt(1).Text
    .SubItems(1) = Txt(2).Text
    .SubItems(2) = Format(PckBirth.Value, "dd/mm/yyyy")
    .SubItems(3) = Txt(4).Text
    .SubItems(4) = Txt(5).Text
    .SubItems(5) = Txt(6).Text
    .SubItems(6) = Txt(7).Text
    .SubItems(7) = Txt(8).Text
    .SubItems(8) = CmbOxygen.Text
    .EnsureVisible
    .Selected = True
    End With
    TmrClose.Enabled = True
    End Sub
    *******************
    please tell me what im doing wrong im stuck with this for 3 hours.

  6. #6
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: how to add & save pic to access with vb 6

    @ salsa31,

    Wrapping your code in [highlight="vb"][/highlight] all make it easiler for people too read.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  7. #7
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    Two things I can see immediately

    1. When inserting a record the Picture is determined from the FileName property of Comon Dialog Control. If a different picture file hasn't been selected by the user then it will have the same picture as the last record inserted.

    2. In your update code you set the Picture column to 'CustPhoto' I don't see anywhere where you actually set that variable to a value.

  8. #8

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    i did at the begining
    Option Explicit
    Dim CustPhoto As String

  9. #9
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    That is just defining the variable as a string. Where do you actually give it a value ?

    eg CustPhoto = <something>

  10. #10

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Nightwalker83 View Post
    @ salsa31,

    Wrapping your code in [highlight="vb"][/highlight] all make it easiler for people too read.
    how do i wrapp?

  11. #11

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Doogle View Post
    That is just defining the variable as a string. Where do you actually give it a value ?

    eg CustPhoto = <something>
    what do you meen?
    the code that i posted is from the project
    like i said
    it adds the cust picture with no problem but when i
    edit the cust and press update and again edit the
    pic dissapears.
    i dont know what to do
    i spen all day with this thing

  12. #12
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    If the CustPhoto variable is not set to anything when you perform the Update it will overwrite whatever was there with a null. If you don't want to update the Photo in the Table then remove it from the update, like this:
    Code:
    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag

  13. #13

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Doogle View Post
    If the CustPhoto variable is not set to anything when you perform the Update it will overwrite whatever was there with a null. If you don't want to update the Photo in the Table then remove it from the update, like this:
    Code:
    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag
    ok.
    but if i want to change the pic then what?
    this will not update the photo my friend
    i got en error
    run time error -2147217900(8004e14)

  14. #14
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    If you want to update the photo then leave the code as it was and set CustPhoto to whatever file the user has chosen before you perform the Update.

    For example: CustPhoto = CmmDlg.FileName

  15. #15

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Doogle View Post
    If you want to update the photo then leave the code as it was and set CustPhoto to whatever file the user has chosen before you perform the Update.

    For example: CustPhoto = CmmDlg.FileName
    i did what you say
    and when i add a new cust and update i get error

    run time error -2147217900(8004e14)
    and where do i put this code
    "CustPhoto = CmmDlg.FileName"

  16. #16
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    Code:
    'and this is the code for update:
    '************************
    CustPhoto = cmmDlg.Filename
    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "', " & _
    "Photo= '" & CustPhoto & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag

  17. #17

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Doogle View Post
    Code:
    'and this is the code for update:
    '************************
    CustPhoto = cmmDlg.Filename
    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "', " & _
    "Photo= '" & CustPhoto & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag
    i did this now
    but when i press edit and update with adding nothing and again edit
    the pic dissapears again lol
    and when i press new cust the pic from the last cust is the same

  18. #18
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    Perhaps it would be better to set CustPhoto in the edit routine. so it will default to that one if the user doesn't select another one.
    Code:
    Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    CustPhoto = RS!Photo
    End Sub
    'and this is the code for update:
    '************************
    If cmmDlg.FileName <> "" Then CustPhoto = cmmDlg.FileName
    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "', " & _
    "Photo= '" & CustPhoto & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag
    If the user hasn't selected a new Photo then the old one will be used.

  19. #19

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Doogle View Post
    Perhaps it would be better to set CustPhoto in the edit routine. so it will default to that one if the user doesn't select another one.
    Code:
    Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    CustPhoto = RS!Photo
    End Sub
    'and this is the code for update:
    '************************
    If cmmDlg.FileName <> "" Then CustPhoto = cmmDlg.FileName
    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "', " & _
    "Photo= '" & CustPhoto & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag
    If the user hasn't selected a new Photo then the old one will be used.
    where do ii put this code
    " Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    CustPhoto = RS!Photo
    End Sub"

  20. #20
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: how to add & save pic to access with vb 6

    Salsa

    This is how to "wrap" your code

    Type this ...

    Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    CustPhoto = RS!Photo
    End Sub

    ... then "select" that code, ie,
    1. move your cursor to the beginning
    2. hold the Shift key down and use the down arrow to highlight to the end
    3. then click the "Code" icon that appears at the top of the editor.

    This is the result ...
    Code:
       Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
       Set BttnPhoto.Picture = LoadPicture(RS!Photo)
       CustPhoto = RS!Photo
    End Sub
    Two main things happen:
    1. the code appears in Courier font and in a grey box to make it "pop out"
    2. all leading spaces (ie, indents) are preserved.

    I hope that helps you

    Spoo

  21. #21

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Spoo View Post
    Salsa

    This is how to "wrap" your code

    Type this ...

    Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    CustPhoto = RS!Photo
    End Sub

    ... then "select" that code, ie,
    1. move your cursor to the beginning
    2. hold the Shift key down and use the down arrow to highlight to the end
    3. then click the "Code" icon that appears at the top of the editor.

    This is the result ...
    Code:
       Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
       Set BttnPhoto.Picture = LoadPicture(RS!Photo)
       CustPhoto = RS!Photo
    End Sub
    Two main things happen:
    1. the code appears in Courier font and in a grey box to make it "pop out"
    2. all leading spaces (ie, indents) are preserved.

    I hope that helps you

    Spoo
    i will try that next time
    its too bad that i didnt find the problem in my project

  22. #22
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by salsa31 View Post
    where do ii put this code
    " Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    CustPhoto = RS!Photo
    End Sub"
    As I suggested, the change should go into the edit code.

    You've already got the first two startements I just added the CustPhoto = RS!Photo statement to it.
    Here's the updated code for edit and update, I've commented the changes I have suggested
    Code:
    'this is the code for edit:
    '***********************
    If LsVw.SelectedItem Is Nothing Then Exit Sub
    Me.Enabled = False
    LsVw.SelectedItem.EnsureVisible
    LsVw.SelectedItem.Selected = True
    LsVw.Enabled = False
    LsVw.BackColor = &H8000000F
    FrCust.Caption = LsVw.SelectedItem & ""
    BttnPhoto.Caption = ""
    ChkRepeat.Enabled = False
    TmrOpen.Enabled = True
    SubBttns
    With LsVw.SelectedItem
        Txt(1).Text = .Text
        Txt(2).Text = .SubItems(1)
        PckBirth.Value = .SubItems(2)
        Txt(4).Text = .SubItems(3)
        Txt(5).Text = .SubItems(4)
        Txt(6).Text = Replace$(.SubItems(5), " - ", "")
        Txt(7).Text = Replace$(.SubItems(6), " - ", "")
        Txt(8).Text = .SubItems(7)
        CmbOxygen.Text = .SubItems(8)
    End With
    Set RS = CN.Execute("SELECT Photo FROM Customers WHERE ID= " & LsVw.SelectedItem.Tag)
    Set BttnPhoto.Picture = LoadPicture(RS!Photo)
    CustPhoto = RS!Photo            ' Added by Doogle to set the default Photo
    End Sub
    'and this is the code for update:
    '************************
    If cmmdlg.FielName <> "" Then CustPhoto = cmddlg.FileName   ' Added by Doogle to set
                                                                ' the Photo to the picture
                                                                ' selected by the user if they
                                                                ' did select one
    CN.Execute "UPDATE Customers SET " & _
    "FullName= '" & RplS(Txt(1).Text) & "', " & _
    "Address= '" & RplS(Txt(2).Text) & "', " & _
    "DateBirth= #" & MyDate(PckBirth.Value) & "#, " & _
    "Facebook= '" & RplS(Txt(4).Text) & "', " & _
    "Email= '" & RplS(Txt(5).Text) & "', " & _
    "Phone= '" & RplS(Txt(6).Text) & "', " & _
    "Cellular= '" & RplS(Txt(7).Text) & "', " & _
    "HairColour= '" & RplS(Txt(8).Text) & "', " & _
    "Oxygen= '" & CmbOxygen.Text & "', " & _
    "Photo= '" & CustPhoto & "' " & _
    "WHERE ID= " & LsVw.SelectedItem.Tag
    
    With LsVw.SelectedItem
        .Text = Txt(1).Text
        .SubItems(1) = Txt(2).Text
        .SubItems(2) = Format(PckBirth.Value, "dd/mm/yyyy")
        .SubItems(3) = Txt(4).Text
        .SubItems(4) = Txt(5).Text
        .SubItems(5) = Txt(6).Text
        .SubItems(6) = Txt(7).Text
        .SubItems(7) = Txt(8).Text
        .SubItems(8) = CmbOxygen.Text
        .EnsureVisible
        .Selected = True
    End With
    TmrClose.Enabled = True

  23. #23

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    thank you Doogle it seems to work perfect!!!!
    but only 2 problems
    when i press the add new cust button
    it shows me the same picture that i added for the previous customer.
    ****************************************************
    Private Sub AddCust()
    ClearDetails
    Me.Enabled = False
    LsVw.Enabled = False
    FrCust.Caption = "NEW CUST"
    If Not LsVw.SelectedItem Is Nothing Then LsVw.SelectedItem.Selected = False
    LsVw.BackColor = &H8000000F
    CmbOxygen.Text = 1
    TxtFind.Enabled = False
    ChkRepeat.Enabled = True
    TmrOpen.Enabled = True
    FrCust.refresh

    SubBttns
    End Sub


    second problem
    when i add the first pic to the the customer
    it shows me the same pic on a difrrent customer
    Last edited by salsa31; Jan 4th, 2012 at 08:37 AM.

  24. #24
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    Perhaps you could Zip your Project up and attach it here.

    From what I can see, the problem is in the Edit and Update processes.

    If you want to Edit the data, the Picture may or may not be changed. How do you determine that in your code ?

    eg I want to edit the details and change the Facebook details and Photo. How do I do that?

  25. #25

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    i added my project
    Last edited by salsa31; Jan 5th, 2012 at 10:44 AM.

  26. #26

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Doogle View Post
    Perhaps you could Zip your Project up and attach it here.

    From what I can see, the problem is in the Edit and Update processes.

    If you want to Edit the data, the Picture may or may not be changed. How do you determine that in your code ?

    eg I want to edit the details and change the Facebook details and Photo. How do I do that?
    this is the project
    http://www.megaupload.com/?d=TP9EV39Z

  27. #27
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: how to add & save pic to access with vb 6

    That appears to be a .rar archive rather than .zip. Unfortunately I can't open .rar files (which is why I suggested .zip)

  28. #28

    Thread Starter
    Enjoy the moment
    Join Date
    Feb 2011
    Location
    Barrio Del pilar madrid spain
    Posts
    5,204

    Re: how to add & save pic to access with vb 6

    Quote Originally Posted by Doogle View Post
    That appears to be a .rar archive rather than .zip. Unfortunately I can't open .rar files (which is why I suggested .zip)
    here
    http://www.megaupload.com/?d=TOEP592N

Posting Permissions

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



Click Here to Expand Forum to Full Width