تفضل أخي الكريم
Public Function Ap_CheckRecordStatus()
Dim RstCheckRecordStatus As New ADODB.Recordset
RstCheckRecordStatus.Open "TblMyTable", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
Select Case RstCheckRecordStatus.EditMode
Case adEditAdd
MsgBox "New Record Has Been Created", vbInformation, "Info MSG"
Case adEditDelete
MsgBox "One Record Has Been Deleted", vbInformation, "Info MSG"
Case adEditInProgress
MsgBox "Record Edit In Progress", vbInformation, "Info MSG"
Case adEditNone
End Select
RstCheckRecordStatus.Close
End Function
يقوم هذا الكود بالتحقق من حالة السجل بطريقة Ado
يتحقق اذا كان احد يعدل في السجل
او يحذف سجل
او يضيف سجل جديد
اذا تحقق هذا الشرط سوف تظهر رسالة مع وصف لحالة السجل
لتجربة كل حالة على حدا
1-الحالة الأولى اذا كان شخص ما يعدل في سجل معين
Public Function Ap_CheckRecordStatus()
Dim RstCheckRecordStatus As New ADODB.Recordset
RstCheckRecordStatus.Open "TblMyTable", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
RstCheckRecordStatus!MyFieldName = "Amjad N. Jamali"
Select Case RstCheckRecordStatus.EditMode
Case adEditAdd
MsgBox "New Record Has Been Created", vbInformation, "Info MSG"
Case adEditDelete
MsgBox "One Record Has Been Deleted", vbInformation, "Info MSG"
Case adEditInProgress
MsgBox "Record Edit In Progress", vbInformation, "Info MSG"
Case adEditNone
End Select
RstCheckRecordStatus.Update
RstCheckRecordStatus.Close
End Function
2- الحالة الثانية اذا كان شخص يحذف سجل
Public Function Ap_CheckRecordStatus()
Dim RstCheckRecordStatus As New ADODB.Recordset
RstCheckRecordStatus.Open "TblMyTable", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
RstCheckRecordStatus.Delete
Select Case RstCheckRecordStatus.EditMode
Case adEditAdd
MsgBox "New Record Has Been Created", vbInformation, "Info MSG"
Case adEditDelete
MsgBox "One Record Has Been Deleted", vbInformation, "Info MSG"
Case adEditInProgress
MsgBox "Record Edit In Progress", vbInformation, "Info MSG"
Case adEditNone
End Select
RstCheckRecordStatus.Close
End Function
3-الحالة الثالة وهي التي حضرتك طلبتها اذا أضاف شخص ما سجل جديد
Public Function Ap_CheckRecordStatus()
Dim RstCheckRecordStatus As New ADODB.Recordset
RstCheckRecordStatus.Open "TblMyTable", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
RstCheckRecordStatus.AddNew
Select Case RstCheckRecordStatus.EditMode
Case adEditAdd
MsgBox "New Record Has Been Created", vbInformation, "Info MSG"
Case adEditDelete
MsgBox "One Record Has Been Deleted", vbInformation, "Info MSG"
Case adEditInProgress
MsgBox "Record Edit In Progress", vbInformation, "Info MSG"
Case adEditNone
End Select
RstCheckRecordStatus.Close
End Function
ولك تحياتي
اخي الكريم كان بودي ان ارفق مثال لحتى سهل عليك الموضوع اكثر من ذلك
لكن اعذرني فلا املك الوقت لذلك
وادعوا لنا بالتوفيق
ابو نادر