i have a form that is called FrmNewCard
i have a listview witch pulls the names and the customers photos from another form.
i added 2 people their with diffrent pictures
e.x salsa31 has a picture of a phone , david has a picture of a mouse
when i click on the listview inside this form i see the 2 name.
if i pick salsa31 i see phone if i pick david i see a picture of a mouse.
im not trying to save the photo only to display it when i open a new card for this customer.
when i save the those 2 names then its ok but when i edit salsa31 i see a picture of a phone.when i edit david i see the same picture as salsa31
why is that?
this is my code when i click on the listview to pick a name and display the pic of the cust(this shows me the right picture of the cust when i click on his name)
this is how i pull the customer name in the form Activate
i also have a commondialog and the photo is declared
i tried to play with it over a hour dont know what is wrong
i have a listview witch pulls the names and the customers photos from another form.
i added 2 people their with diffrent pictures
e.x salsa31 has a picture of a phone , david has a picture of a mouse
when i click on the listview inside this form i see the 2 name.
if i pick salsa31 i see phone if i pick david i see a picture of a mouse.
im not trying to save the photo only to display it when i open a new card for this customer.
when i save the those 2 names then its ok but when i edit salsa31 i see a picture of a phone.when i edit david i see the same picture as salsa31
why is that?
this is my code when i click on the listview to pick a name and display the pic of the cust(this shows me the right picture of the cust when i click on his name)
Code:
Private Sub LsVw1_click()
If LsVw1.ListItems.Count = 0 Then
Exit Sub
End If
TxtDesc.text = LsVw1.SelectedItem.SubItems(1)
Picture234.Visible = False
Set rs = CN.Execute("SELECT Photo FROM Customers Where ID= " & CLng(FrmCusts.LsVw.SelectedItem.Tag))
If Not (rs.EOF) Then
If Dir$(rs!Photo) <> "" Then
Set BttnPhoto.Picture = LoadPicture(rs!Photo)
CustPhoto = rs!Photo
Else
MsgBox "the picture has been deleted from the customers table", vbExclamation
CustPhoto = ""
Set BttnPhoto.Picture = Nothing
End If
End If
End Sub
this is how i pull the customer name in the form Activate
Code:
CmmDlg.InitDir = App.Path
CustPhoto = CmmDlg.FileName
Set rs = CN.Execute("select * FROM Customers ORDER BY ID")
Do While Not rs.EOF
Set itm = LsVw1.ListItems.Add(, , rs!ID, , "custlist")
itm.Tag = rs!ID
itm.SubItems(1) = rs!FullName
rs.MoveNext
Loop
Code:
Option Explicit
Dim CustPhoto As String
Code:
Private Sub BttnPhoto_Click()
On Error Resume Next
CmmDlg.DialogTitle = ""
CmmDlg.Filter = "Pictures (*.bmp;*.ico;*.jpg;*.gif)|*.bmp;*.ico;*.jpg;*.gif"
CmmDlg.FileName = ""
CmmDlg.ShowOpen
If CmmDlg.FileName <> "" Then
Set BttnPhoto.Picture = LoadPicture(CmmDlg.FileName)
CustPhoto = CmmDlg.FileName
End If
End Sub