|
-
May 23rd, 2000, 04:08 PM
#1
Thread Starter
New Member
Hi all,
Help on Data Reports. We are using VB6.0.
We need to get the data from a form in the sql query for a data report. eg: we need to get the list of bills in a particular range of dates. The range of dates is specified in a form. So we need to get these dates in the 'where' clause of the SQL (data source of the data report/SQL of the Command object of the Data Environment) statement.
Thanx in advance
BSTL
-
May 23rd, 2000, 08:48 PM
#2
Lively Member
This should give you the idea. I'm using the Date Picker controls but text boxes will work as well. The query is named QueryDate and data report is drDate.
Code:
SELECT `Bills`, `Description`, `Date`
FROM TableName
WHERE (`Date` >= ?) AND (`Date` <= ?)
ORDER BY `Date`
Put this under a command button:
Code:
DataEnvironment1.DataConnection.Open
DataEnvironment1.QueryDate DatePicker1, DatePicker2
drDate.Show
drDate.PrintReport True
DataEnvironment1.DataConnection.Close
If you have any other questions just post them & I'll see what I can do.
[Edited by Dr_Evil on 05-24-2000 at 09:49 AM]
Dr_Evil
Senior Programmer
VS6 EE
VS.NET EA
-
May 24th, 2000, 03:38 PM
#3
Thread Starter
New Member
Thanx for the help.
We tried out the code mentioned. We set QueryDate as a function in which we set the SQL statement. All other conditions as required. But we get an error "Data type mismatch in criteria ". This occurs even when we give simple SQL statements like "Select * from tablename"
Code: (General of DataEnvironment1)
----------------------------------------
Public Function QueryDate(txt1 As String, txt2 As String) As String
QueryDate = "SELECT Billdate, billno From tablename" 'WHERE billDate >=" & txt1 & " AND billDate <=" & txt2 & " ORDER BY billDate"
End Function
------------------------------------------
Code: on command button click
-----------------------------------------
Private Sub Command1_Click()
MsgBox DataEnvironment1.QueryDate(Text1, Text2)
DataEnvironment1.Connection1.Open
DataEnvironment1.QueryDate Text1, Text2
drDate.Show
drDate.PrintReport True
DataEnvironment1.Connection1.Close
End Sub
-------------------------------------------
Thanx in advance
BSTL
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|