Microsoft KB Archive/101252: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 44: Line 44:
== SYMPTOMS ==
== SYMPTOMS ==


Using the ActiveForm Property of the Screen control or an MDI Parent form to reference a Data control causes a "Type Mismatch" error in Visual Basic.
Using the ActiveForm Property of the Screen control or an MDI Parent form to reference a Data control causes a "Type Mismatch" error in Visual Basic.


</div>
</div>
Line 51: Line 51:
== CAUSE ==
== CAUSE ==


This behavior is by design. This is not a bug in Visual Basic. The Visual Basic environment does not know in advance that the Active form will actually contain a Data control, so it generates a &quot;Type mismatch&quot; error.
This behavior is by design. This is not a bug in Visual Basic. The Visual Basic environment does not know in advance that the Active form will actually contain a Data control, so it generates a "Type mismatch" error.


</div>
</div>
Line 58: Line 58:
== WORKAROUND ==
== WORKAROUND ==


To avoid the error message, use global objects to reference the local controls. The &quot;More Information&quot; section below demonstrates one method for doing this.
To avoid the error message, use global objects to reference the local controls. The "More Information" section below demonstrates one method for doing this.


</div>
</div>
Line 74: Line 74:
=== Steps to Correct Problem ===
=== Steps to Correct Problem ===


This example shows how to correct the problem. First, create the problem by following the steps listed in &quot;Steps to Reproduce Problem.&quot; Then correct the problem with these steps:<br />
This example shows how to correct the problem. First, create the problem by following the steps listed in "Steps to Reproduce Problem." Then correct the problem with these steps:<br />
<br />
<br />


Line 107: Line 107:
<li>From the Run menu, choose start (ALT, R, S) or press the F5 key.</li></ol>
<li>From the Run menu, choose start (ALT, R, S) or press the F5 key.</li></ol>


A &quot;Type mismatch&quot; error will occur on the Set statement.
A "Type mismatch" error will occur on the Set statement.


</div>
</div>

Latest revision as of 09:17, 20 July 2020

Article ID: 101252

Article Last Modified on 1/8/2003



APPLIES TO

  • Microsoft Visual Basic 3.0 Professional Edition



This article was previously published under Q101252

SYMPTOMS

Using the ActiveForm Property of the Screen control or an MDI Parent form to reference a Data control causes a "Type Mismatch" error in Visual Basic.

CAUSE

This behavior is by design. This is not a bug in Visual Basic. The Visual Basic environment does not know in advance that the Active form will actually contain a Data control, so it generates a "Type mismatch" error.

WORKAROUND

To avoid the error message, use global objects to reference the local controls. The "More Information" section below demonstrates one method for doing this.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Correct Problem

This example shows how to correct the problem. First, create the problem by following the steps listed in "Steps to Reproduce Problem." Then correct the problem with these steps:

  1. Add the following code to the Form_Activate Event:

       Sub Form_Activate ()
          Set CurrentDS = Data1.Recordset
       End Sub
                            
  2. Change two lines of code into comments by adding a single quotation mark to the beginning of the line. Change the Set CurrentDS statement in the Set_CurrentDS Sub in Module1 to a comment, and do the same to the Call Set_CurrentDS statement in the Form_Click event of Form1.

Steps to Reproduce Problem

  1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.
  2. Add a data control (Data1) to Form1.
  3. Set the DatabaseName Property of Data1 to BIBLIO.MDB.
  4. From the File menu, choose New Module (ALT, F, M). Module1 is created.
  5. Add the following code to the General section of Module1:

       Global CurrentDS As DynaSet
                            
  6. Add the following code to Module1:

       Sub Set_CurrentDS ()
          Set CurrentDS = Screen.ActiveForm.Data1.Recordset
       End Sub
                            
  7. Add the following code to the Form_Click event procedure of Form1:

       Sub Form_Click ()
          Call Set_CurrentDS
       End Sub
                            
  8. From the Run menu, choose start (ALT, R, S) or press the F5 key.

A "Type mismatch" error will occur on the Set statement.


Additional query words: 3.00 errmsg

Keywords: kbprb KB101252