I got this sample project from a website. But there is some syntax error in the statement which contains the CDate function. I can't detect the error? Can enybody help me?
SUMMARY
This article demonstrates basing a DataReport on a parameterized DataEnvironment and refreshing the report when the parameter value changes.
MORE INFORMATION
1.
Open a new Standard EXE Project in Microsoft Visual Basic. Form1 is created by default.
2. Add a DataEnvironment (DataEnvironmen t1) and a DataReport (DataReport1) to the project.
3. Add a Connection (Connection1) to the DataEnvironment pointing to NWIND.MDB (or Northwind.MDB) through the Microsoft Jet 4.0 OLE DB Provider.
4. Add a Command (Command1) to Connection1, with the following properties:
CommandType: adCommandText
CommandText: Select * From Employees Where HireDate < ?
In the Parameters tab:
Name: pDate
Direction: Input
Data Type: adDBTimeStamp
Host Data Type: Date (VT_DATE)
5. In the DataReport, set the following properties:
DataSource: DataEnvironment 1
DataMember: Command1
6. Drag the following fields from the DataEnvironment into the Detail section of the DataReport:
EmployeeID
FirstName
LastName
HireDate
7. Add a TextBox (Text1) and a CommandButton (Command1) to the form. Add the following code:
Option Explicit Private Sub Command1_Click( ) Load DataEnvironment 1 With DataEnvironment 1 If .rsCommand1.Sta te <> 0 Then .rsCommand1.Clo se .Command1 CDate(Text1.Tex t) End With DataReport1.Ref resh If DataReport1.Vis ible = False Then DataReport1.Sho w End Sub
8. Save the project and run it. Enter the following dates in the TextBox and click the CommandButton after each one:
1/1/95
1/1/94
1/1/93
1/1/92
You can see the report refresh showing only those employees hired prior to the date entered.
SUMMARY
This article demonstrates basing a DataReport on a parameterized DataEnvironment and refreshing the report when the parameter value changes.
MORE INFORMATION
1.
Open a new Standard EXE Project in Microsoft Visual Basic. Form1 is created by default.
2. Add a DataEnvironment (DataEnvironmen t1) and a DataReport (DataReport1) to the project.
3. Add a Connection (Connection1) to the DataEnvironment pointing to NWIND.MDB (or Northwind.MDB) through the Microsoft Jet 4.0 OLE DB Provider.
4. Add a Command (Command1) to Connection1, with the following properties:
CommandType: adCommandText
CommandText: Select * From Employees Where HireDate < ?
In the Parameters tab:
Name: pDate
Direction: Input
Data Type: adDBTimeStamp
Host Data Type: Date (VT_DATE)
5. In the DataReport, set the following properties:
DataSource: DataEnvironment 1
DataMember: Command1
6. Drag the following fields from the DataEnvironment into the Detail section of the DataReport:
EmployeeID
FirstName
LastName
HireDate
7. Add a TextBox (Text1) and a CommandButton (Command1) to the form. Add the following code:
Option Explicit Private Sub Command1_Click( ) Load DataEnvironment 1 With DataEnvironment 1 If .rsCommand1.Sta te <> 0 Then .rsCommand1.Clo se .Command1 CDate(Text1.Tex t) End With DataReport1.Ref resh If DataReport1.Vis ible = False Then DataReport1.Sho w End Sub
8. Save the project and run it. Enter the following dates in the TextBox and click the CommandButton after each one:
1/1/95
1/1/94
1/1/93
1/1/92
You can see the report refresh showing only those employees hired prior to the date entered.
Comment