473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

DataReport on a parameterized DataEnvironment

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 (DataEnvironment1) 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: DataEnvironment1
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 DataEnvironment1 With DataEnvironment1 If .rsCommand1.State <> 0 Then .rsCommand1.Close .Command1 CDate(Text1.Text) End With DataReport1.Refresh If DataReport1.Visible = False Then DataReport1.Show 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.
Sep 18 '08 #1
1 3313
smartchap
236 100+
I don't find any error in the code. May be you tyoed code wrongly. Use the code as below:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub Command1_Click()
  4.     Load DataEnvironment1
  5.     With DataEnvironment1
  6.         If .rsCommand1.State <> 0 Then .rsCommand1.Close
  7.         .Command1 CDate(Text1.Text)
  8.     End With
  9.     DataReport1.Refresh
  10.     If DataReport1.Visible = False Then DataReport1.Show
  11. End Sub
  12.  
Oct 10 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: berthelot samuel | last post by:
Hi everyone, I am currently trying to write a report based on a View of SQL Server. Basically, I have 3 tables : Hardware, SoftwareInstalled and Software with SoftwareInstalled that keeps track of...
2
by: Allcomp | last post by:
Hello, I am trying to learn how to work in Visual Studio .Net 2005 and after searching for a lot, I don't see any answer. Actually, In VB6 I use the dataenvironment. For my application, I...
1
by: hanna22 | last post by:
i want to know how i can use commands (in dataenvironment ) with datareports i made tow commands that contain an sql statements baut the property(data member) of the text control in my report...
1
by: pramodrepaka | last post by:
I am using Vb6. I am using data report in my program I have it working but when I print it is printing all the records in the database. I am having troubles with it printing a single record. with the...
18
by: vishwaskothari | last post by:
i need to develop a dynamic datareport . here by the word dynamic i mean that the contents of the report will vary according to the users input. for eg : i am doing a search operation.and the...
0
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, If i made some changes to a datareport suppose some updates are made then if i opens the report it is not updated. Datareport is connected to dataenvironment. If i use crystalreports does...
1
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I want to connect my datareport to a dataenvironment programatically. And i m using this code for this purpose but it does not working with an error. DR.DataSource = "DE" DR.DataMember...
3
by: RAM28079 | last post by:
i created a dataenvironment command with 2 query parameters which were received from the user through form. one for numeric datatype and another for a string datatype. when i call the report using...
2
by: hussainiyad | last post by:
Dear all , I,m working with small invoice project and i need the report for 1.Purchase Order 2.SalesInvoice 3.Total stock, so created 3 dataenvironment and 3 DataReports and i created the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.