BUG: Data Form Wizard via Application Wizard Omits ADO Reference
ID: Q193326
|
The information in this article applies to:
-
Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0
-
ActiveX Data Objects (ADO), versions 2.0, 2.1, 2.1 SP2
SYMPTOMS
When running an application created using the Application Wizard, you
receive the following:
"Compile error: User-defined type not defined"
CAUSE
The Application Wizard allows for the creation of forms via the Data Form
Wizard. When a form is created in this manner, a reference to ADO is not
added to the project.
RESOLUTION
Add a reference to ADO by selecting References from the Project menu and
checking the box next to "Microsoft ActiveX Data Objects Library."
This problem can also be avoided by running through the Application Wizard
without adding any data forms, then adding data forms by invoking the Data
Form Wizard directly from the Add-Ins menu.
To work around this new compile error, you muct 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)
And change:
Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
-to-
Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset20)
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
MORE INFORMATION
Steps to Reproduce Behavior
- Select New Project from the File menu.
- In the New Project dialog box, select Visual Basic Application Wizard and click OK.
- Click Next on each page of the Wizard until you reach the
page titled "Data Access Forms."
- Click Create New Form.
The following instructions refer to the Data Form Wizard, which is
invoked at step 4.
- Click Next.
- Select a database type and click Next.
- Enter the requested connection information and click Next.
- Select "Grid (Datasheet)" as the Form Layout, select ADO Data Control
as the Binding Type, and then click Next.
- Select a Record Source and at least one field, and then click Next.
- Click Finish, and click No when prompted to create another form.
- Click Finish.
- Attempt to run the created project. The result is:
Compile error: User-defined type not defined.
The workaround is as specified in the "Resolution" section earlier.
REFERENCES
For additional information Compile error: Procedure declaration does not match description of event or procedure having the same name, click the article number below
to view the article in the Microsoft Knowledge Base:
Q222145 PRB: ADO Data Control Events May Generate a Compilation Error
Additional query words:
Keywords : kberrmsg kbwizard kbADO kbADO200 kbCtrl kbDatabase kbVBp kbVBp600bug kbAppWizard kbGrpVBDB kbGrpMDAC kbDSupport kbADO210sp2
Version : WINDOWS:2.0,2.1,2.1 SP2,6.0
Platform : WINDOWS
Issue type : kbbug