Click to See Complete Forum and Search --> : Help on Data Reports in VB6.0
bstl
May 23rd, 2000, 04:08 PM
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
Dr_Evil
May 23rd, 2000, 08:48 PM
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.
SELECT `Bills`, `Description`, `Date`
FROM TableName
WHERE (`Date` >= ?) AND (`Date` <= ?)
ORDER BY `Date`
Put this under a command button:
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]
bstl
May 24th, 2000, 03:38 PM
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.