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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete

Status
Not open for further replies.

arshia

Programmer
Oct 10, 2000
4
CA
Hello!

I am trying to delete a whole row of data in the data base.
I can't find the right code. I know how to change the existing data and then update the database but now, I am trying to delete a row and I can't. BTW, i am using ASP and Access for database.

Thanks and Cheers

ArshiA
[sig][/sig]
 
This code would work

Dim DB as Database
Dim rstRecordset as Recordset

Set DB = DBEngine(0)(0)
Set rstRecordset = DB.Openrecordset(<<Your Recordset>>, _ DBOpenDynaset)

Do until rstRecordset.EOF
.delete
.movenext
Loop

Simple but don't know if this answers your question
[sig][/sig]
 
' You can also use the following function to delete a specific record, or group of
' records that meet a specific criteria


Function DeleteRecords(strTblName As String, strFldName As String, strFldVal As String)
' strTableName is the name of the table that you want to remove the row (record) from.
' strFldName is the name of the field that you're searching for specific criteria in.
' strFldVal is the value, or criteria, that you want met, in order find records to delete.

' Also, this might be helpful for you: Access will prompt you, letting you know that you're going
' to delete X number of records. If you don't want this to happen, uncomment the following line
' as well as the line after the DoCmd line.
' MAKE SURE if you ever SetWarnings to False, that you turn them back on by the SetWarnings True.
' If you don't, you wont get ANY warnings for things you do (accidentaly click delete when a table
' is selected, and it's gone. No warnings. Bye bye.

' DoCmd.SetWarnings False
DoCmd.RunSQL (&quot;SELECT * FROM &quot; & strTblName & &quot; WHERE &quot; & strFldName & &quot; = '&quot; & strFldVal & &quot;';&quot;)
' DoCmd.SetWarnings True
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top