VB資料庫資料的選項錄入及增減與編輯之二

來源:互聯網
上載者:User

 在連續錄入的幾條記錄中,同名欄位的內容完全相同或基本相同,此時若能充分利用 資料庫中的已有資料,設定一個複製鍵將上條記錄中的同名欄位的內容複寫到目前記錄的同名欄位中,將能大提高資料錄入速度。

為了便於使用者操作,將這一功能賦予ctrl鍵,使用者在錄入新記錄或編輯原有記錄時,只要按下ctrl鍵,則上條記錄中的同名欄位的內容就複製到目前記錄的同名欄位中。程式如下:

option explicit

dim last as string

private sub form-activate()

dim mark as variant

mark=data1.recordset.bookmark

data1.recordset.movelast

last=data1.recordset("name")

data1.recordset.bookmark=mark

end sub

private sub text1-keydown

(keycode as integer,shift as integer)

if shift=2 then ’按下ctrl-key複製上條記錄中的同名欄位的內容

if data1.recordset.editmode=dbeditinprogress

or data1.recordset.editmode=dbeditadd then

text1.text=last

end if

end if

end sub

private sub command1-click(index as integer)

select case index

case0’addnew

data1.recordset.addnew

text1.setfocus

case1’edit

data1.recordset.edit

text1.setfocus

case2’giveup

data1.recordset.cance1update

data1.refresh

case3’save

data1.recordset. update

data1.recordset.movelast

last=data1.recordset("name") ’save the text to last

data1.refresh

case4’delete

data1.recordset.delete

data1.refresh

end

end select

end sub

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.