Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Records in Access 2000 Help please needed urgently

Status
Not open for further replies.

Jaked

Instructor
Mar 4, 2002
7
0
0
ZA
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top