Hi I have this form which works well when it is in list box. but when I change the list box to combo box, the form does not works and I will be stuck at "record does not exist" even though i choose the record from the combo box. this form works mainly by using vb and these are the code for the form:
Private Sub Command23_Click()
'On Error GoTo errhandler
'....................Deleting Agent details.........'
Dim dbs As Database, rst As Recordset
Dim tco, i, ITM, lhm, kk As Variant
kk = 0
For Each ITM In Lsta.ItemsSelected
lag1 = Lsta.Column(0, ITM)
lhm = Lsta.Column(1, ITM)
Next ITM
Tagent1.SetFocus
Tagent1.Text = lag1
thmcode.SetFocus
thmcode.Text = lhm
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("agent")
rst.Index = "PrimaryKey"
With rst
If .EOF Then
Else
.Seek "=", lag1
If .NoMatch Then
Msg = "Record does not exist !!"
Style = vbOKOnly + vbExclamation
Title = "Chemical Deletion"
Response = MsgBox(Msg, Style, Title)
Else
Msg = "Do you want to delete this record ?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Chemical Deletion"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Msg = " Record deleted !!"
Style = vbOKOnly + vbCritical
Title = "Chemical Deletion"
Response = MsgBox(Msg, Style, Title)
.DELETE
kk = 1
Else
Msg = " Record not deleted !!"
Style = vbOKOnly + vbInformation
Title = "Chemical Deletion"
Response = MsgBox(Msg, Style, Title)
End If
End If
End If
End With
rst.Close