ACCESS記錄的刪除和讀寫(xiě)

字號(hào):

清空表記錄的方法
    1、CurrentDb().Execute \"delete * from 表名\"
    2、docmd.runsql \"SQL語(yǔ)句\"
    3,RunSQL \"Delete * From 表名\"
    確定所顯示的當(dāng)前記錄的記錄編號(hào)。
    下面的示例顯示如何使用
    Currentrecord 屬性來(lái)確定所顯示的當(dāng)前記錄的記錄編號(hào)。在通用過(guò)程 Currentformrecord 中將當(dāng)前記錄的編號(hào)值賦給變量 Lngrecordnum。
    Sub CurrentFormRecord(frm As Form)
    Dim lngrecordnum As Long
    lngrecordnum = frm.CurrentRecord \’CurrentRecord是當(dāng)前記錄號(hào)
    End Sub
    讀取最后一條記錄
    dlast(\"字段名\",\"表名\")
    在字段默認(rèn)值中用此函數(shù)能使該字段的新紀(jì)錄顯示上一條記錄該字段的值
    怎樣使窗體一打開(kāi)就定位到指定記錄上
    定義了一個(gè)變量lngbh,要窗體打開(kāi)時(shí)顯示ID=Lngbh的這條記錄。
    DoCmd.OpenForm \"formname\", acNormal, , \"ID =\" & LNGBH, acFormEdit, acWindowNormal
    如何在打開(kāi)窗體時(shí)自動(dòng)到相應(yīng)記錄
    用法:DoCmd.RunCommand acCmdRecordsGoToNew
    acCmdRecordsGoToFirst 移到第一條記錄
    acCmdRecordsGoToLast 移到最后一條記錄
    acCmdRecordsGoToNew 新增一條記錄
    acCmdRecordsGoToNext 移到下一條記錄
    acCmdRecordsGoToPrevious 移到上一條記錄
    判斷記錄的位置
    me.Recordset.AbsolutePosition = 0 \’第一條記錄
    me.Recordset.AbsolutePosition = me.Recordset.RecordCount -1 \’最后一條記錄
    me.Recordset.AbsolutePosition=-1 \’第一條記錄前 me.Recordset.bof=true
    me.Recordset.AbsolutePosition=me.Recordset.RecordCount \’最后一條記錄后 me.Recordset.eof=true
    me.Recordset.AbsolutePosition=n \’第n+1條記錄
    判斷是否為新增記錄
    me.newrecord=true
    me.newrecord=false
    VB語(yǔ)句刪除記錄:
    For I = 1 To 20
    SQL = \"Delete 訂單明細(xì)ID FROM 訂單明細(xì) Where 訂單明細(xì)ID=\" & I
    DoCmd.RunSQL SQL
    Next
    或:
    CurrentProject.Connection.Execute \"Delete * FROM要?jiǎng)h除記錄的表\"