Procedure declaration does not match description of event or procedure having the same name
意思是“过程声明与过程描述不匹配或者过程重名”,于是到源程序中查看,问题出在事件上:
Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
In versions of Visual Basic 6 prior to Service Pack 4, the ADO Data Control's events were designed to work only with ADO version 2.0. After you set a Reference to ADO later than 2.0 to workaround the Application Wizard problem, you receive the following error message
Compile Error: Procedure declaration does not match description of event or procedure having the same name.
To work around this new compile error, you must change the declaration of the ADO Data Control's events to include ADODB.Recordset20 instead of ADODB.Recordset.
Specifically, change the following event procedure:
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
-to-
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset20)
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
改成:
Private Sub datPrimaryRS_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset20)
2- then so that the form reseives event from Adodc I did this
Private Sub Form_Load()
Set db = Adodc1.Recordset
End Sub
Now when i select db in forms object i can see the events and they are generated automatic
Private Sub db_MoveComplete(ByVal adReason As ADODB.EventReasonEnum,
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
MsgBox "It works"
End Sub
========================
我把这段主要意思翻译下:
1、先在窗体加上声明:
Option Explicit
Dim WithEvents db As ADODB.Recordset
2、在主窗体Load事件中加上
Private Sub Form_Load()
Set db = Adodc1.Recordset
End Sub
3、更改ADODC的事件声明为
Private Sub db_MoveComplete(ByVal adReason As ADODB.EventReasonEnum,
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)