954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

make a datareport with condition

I made a datareport simple. just connect. but I want to make it with condition. I have 2
dtpicker for date. I want 1 day report or weekly or monthly report by dtpicker. example
I want 03/11/08 report or 01/11/08 to 03/11/08 report. But I dont know how make it. Where I write code or how I collect it. Help me. I want I select a date from dtpicker or form both dtpicker and click a button then the report show.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

you need to frame the sql dynamically at runtime and pass the same to the report.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

hi. you can write the query first. then i think you have to set the record source of your report
to the query you made.

AUGXIS
Light Poster
45 posts since Dec 2007
Reputation Points: 11
Solved Threads: 11
 

>> you need to frame the sql dynamically at runtime and pass the same to the report.

how can I pass to the report?

>>hi. you can write the query first. then i think you have to set the record source of your report
to the query you made.

How can I connect between the button and the report. I meant when I select date and press button then how the report show by code.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

hi. you try to make a query first.say

rs.Open "Select appdate, name from tablename where  appdate between '" & date1 & "' AND '" & date2 & "'"

then set the record source of the report

Set repo.DataSource = rs
repo.Title = "Hello"
repo.Show
AUGXIS
Light Poster
45 posts since Dec 2007
Reputation Points: 11
Solved Threads: 11
 

when I made report I use adodc control by DSN. table select by code like
"select * from table1". I use adodc control in full project and connect with property
not by code.
so help me with details code. I didn't understand your code.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

I need help. please help me with details.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

help me

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

Hi Abu,

Well... Follow these Steps:
Open a Data Project
Add a Connection Object (Configure to your database)
Add A Command Object (Say Command1) And Right-Click
Goto properties and Select Option SQL Statement and Type :
Select * From MyTable Where MyDate Between ? And ?
Click on Apply,
Parameter Tab Is Enabled, Go there..
Set these properties for both Parameters:
DataType = adDBDate
HostDataType =Date (VT_Date)
And Apply,
Save the Project
Now Design the DataReport1 on this Command Object...

In The Calling Form, Place 2 Date Pickers say DTFr and DTTo

Place Command Button And Show the Report like this :

Load DataEnvironment1
With DataEnvironment1
If .rsCommand1.State <> 0 Then .rsCommand1.Close
.Command1 Format(DTFr.Value,"dd-mm-yyyy"), Format(DTTo.Value,"dd-mm-yyyy")
End With
DataReport1.Show

I HOPE IT IS CLEAR..

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

thanks veena its work well.
but I have a few question.
1. Set these properties for both Parameters:
DataType = adDBDate
HostDataType =Date (VT_Date)
if I want to search number then what i need to change?
if need to search name or string then....?
please help me with this question.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

Hi,

For Numeric(Long)
adBigInt, Long

For Text :
adVarChar, String

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

hello abu,
pls try this code if this will work.

("Select * from TableName where IDate <= cDate (' " & CStr(DTPicker1.Value) & " ') and IDate >= cDate(' " & CStr(DTPicker2.Value) & " ')")

or
If DTPicker1.Value <= !IDate And DTPicker2.Value >= !IDate Then


Regards,

denine

denine
Newbie Poster
7 posts since Nov 2008
Reputation Points: 10
Solved Threads: 1
 

Dear veena
I have a problem. I write code in sql like
select * from table1
so all field show. help me what I write for particular field. I write....
select Student name from table1
what I write? some time parametre not show.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

Hi,

Yes, You can write all the field names from the table...
eg:

Select EmpID,EmpName From EmpMas Where EmpID = ?

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

I write like you but no field show but parametre was shown. If i write only this
select * from table1
then show all fields. but when I write your past code it was worked.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

Please any body help me.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

anybody help me please

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

Hi,

Post your SQL statement here..

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

SELECT * FROM incomereport WHERE AccountinfoDate AND IncomeDate BETWEEN ? AND ?

1st I write this code and it work after I write for other

SELECT Student ID, Student Name, Jamat Name, Feeding Charge,
Exam Fee, Roll No, Jamat Fee, Others Fee, AccountinfoDate,
Father 's Name,Category,Contact No,Address,Admission Date From stdreport Where Student ID ?
this code not work.

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

anybody can help me with this thread please

abu taher
Practically a Posting Shark
845 posts since Jul 2008
Reputation Points: 14
Solved Threads: 78
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You