dim objRs as New Recordset dim objCn as New connection dim strSql as string objCn.ConnectionString="fileDsn=student.dsn;User_Id=sa;PassWord=123" objcn.open strSql="SELECT * FROM Student_info" objRs.Open strSql ,objCn,adOpenKeyset, adLockOptimistic '在這判斷,若為空則告知用戶并退出該模塊操作就行了 if objRS.RecordsetCount=0 then msgbox "學籍信息不存在,請補充后在操作!" objRs.Close Set objRs=Nothing exit sub '這一步可別忘了,要不然還得報錯,原因是依舊執行了以后的操作 end if (){ }