VBA/Excel/Access/Word/Access/Recordset Delete — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 15:46, 26 мая 2010
Deleting an Existing Record from Recordset
<source lang="vb">
Sub DeleteCusts(lngProjEst As Long)
Dim intCounter as Integer Dim rst As ADODB.Recordset Set rst = New ADODB.Recordset rst.ActiveConnection = CurrentProject.Connection rst.CursorType = adOpenDynamic rst.LockType = adLockOptimistic rst.Open "Select * from Products " intCounter = 0 Do Until rst.EOF If rst("UnitPrice") < lngProjEst Then rst.Delete intCounter = intCounter + 1 End If If Not rst.EOF Then rst.MoveNext End If Loop Debug.Print intCounter & " Customers Deleted" rst.Close Set rst = Nothing
End Sub
</source>
Removing a Table Using Code
<source lang="vb">
Sub DeleteTable()
On Error Resume Next Dim cat As ADOX.Catalog Set cat = New ADOX.Catalog cat.ActiveConnection = CurrentProject.Connection cat.Tables.Delete "Foods"
End Sub
</source>