User Makes input in the TextBox for selecting the record for deletion
Option Explicit
Dim tmp as adodb.recordset
'in the TextBox change event
private sub Text1_Change()
Call CheckRecord trim(Text1.Text)
end sub
private sub CheckRecord(x as String)
set tmp = new adodb.recordset
tmp.open " select * from Your_table where Your_Field = '" & x & "'",Connection,adOpenKeyset, adLockOptimistic
if tmp.recordcount > 0 then
Lable1.Caption = "Record Exist"
else
Lable1.Caption = "Record Does Not Exist"
end if
end sub
Private sub Command1_click()
dim del
del = msgbox(" Confirm delete ? ",vbyesNo)
if del = vbyes then
tmp.delete
tmp.update
end if
end sub
Assumed that the search field is string (advarchar)
if it is numeric
use
select * from your_table where field_name = " & x , connection,adOpenKeyset,adlockOptimistic
in the textbox use
call CheckRecord val(text1.text)