Microsoft KB Archive/257938

{|
 * width="100%"|

PRB: Activate Event of DataReport Does Not Fire Initially

 * }

Q257938

-

The information in this article applies to:


 * Microsoft Visual Basic Professional Edition for Windows, version 6.0, on platform(s):
 * the operating system: Microsoft Windows NT
 * the operating system: Microsoft Windows 95
 * the operating system: Microsoft Windows 98
 * Microsoft Visual Basic Enterprise Edition for Windows, version 6.0, on platform(s):
 * the operating system: Microsoft Windows NT
 * the operating system: Microsoft Windows 95
 * the operating system: Microsoft Windows 98

-

SYMPTOMS
The Activate event of a DataReport does not fire initially on a Microsoft Windows NT 4.0-based computer, a Microsoft Windows 95-based computer or a Microsoft Windows 98-based computer.

RESOLUTION
To work around this problem:


 * 1) Load the DataReport.
 * 2) Set the focus away from the report.
 * 3) Show the report.

For example:

Load DataReport1 Me.SetFocus '(Sets the focus to the form.) DataReport1.Show

STATUS
This behavior no longer occurs under Microsoft Windows 2000.

MORE INFORMATION
The following statement is in the Microsoft Visual Basic Online Help, under the DataReport Events topic:

"'The Activate event occurs when the designer becomes the active window.'" The report becomes the active window as soon as it displays, yet it does not fire the event initially. If you display the report, click another window, and then click back to the report, the event fires.

Steps to Reproduce Behavior

 * 1) Start a new Visual Basic Standard EXE project. Form1 is added by default.
 * 2) From the Project menu, click References, and then select Microsoft ActiveX Data Objects 2.0 or later.
 * 3) From the Project menu, select Add Data Report. If there is not an option for a Data Report, from the Project menu, click Components. A dialog box displays. Click the Designers tab, and then add a reference to the Data Report.
 * 4) Add a DataEnvironment.
 * 5) Set a connection and a command object for the DataEnvironment.
 * 6) Set the DataSource and DataMember properties of the DataReport.
 * 7) Place a command button on Form1.
 * 8) Place the following code into the Command1_Click event:
 * 9) Place the following code in the DataReport_Activate event of the DataReport:
 * 10) Run the project, and then click Command1.
 * 11) Uncomment the first two lines in Command1_Click.
 * 12) Run the project again.