I am looking for a code where I can search for a specific Record in a Access 2000 and when it is found to click on another command button to delete it. Can someone help me please
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)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.