elow, can any1 tell me whats the code for deleting a record in a database??
or deleting a row?
my table is consist of fields..
lecID
arlNumber
arlLec
arlPart
thx in advance to,
elow, can any1 tell me whats the code for deleting a record in a database??
or deleting a row?
my table is consist of fields..
lecID
arlNumber
arlLec
arlPart
thx in advance to,
' Here is the code -- beware I am deleting all Rows.. Please add condition to the query
' I would also advise you to modify the logic in future, to retain the row and flag the row as delete
Sub Delete_Rows()
Dim Cn As ADODB.Connection '* Connection String
Dim oCM As ADODB.Command '* Command Object
Dim sQuery As String '* Query String
Dim lRow
On Error GoTo ADO_ERROR
Set Cn = New ADODB.Connection
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Documents and Settings\160831\My Documents\db4.mdb';Persist Security Info=False"
Cn.ConnectionTimeout = 40
Cn.Open
Set oCM = New ADODB.Command
oCM.ActiveConnection = Cn
oCM.CommandText = "Delete From Sample"
oCM.Execute lRow
MsgBox "Deleted " & lRow & " rows"
Application.StatusBar = False
If Not oCM Is Nothing Then Set oCM = Nothing
If Not Cn Is Nothing Then Set Cn = Nothing
ADO_ERROR:
If Err <> 0 Then
Debug.Assert Err = 0
MsgBox Err.Description
Resume Next
End If
End Sub
Ty sir ive solve my prob about this
thx!!!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.