[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to filter from two dates to generate a data report in VB6

Posted on 2004-10-27
7
Medium Priority
?
2,025 Views
Last Modified: 2010-04-29

hi experts

could any one help me on this.

I want to generate a data report filtered by two dates,
I currently use the following method to filter with one date.

Private Sub Command1_Click()
Dim sDate As String
 sDate = Format(CDate(Text1), "mm-dd-yyyy")
   MsgBox sDate
   DataEnvironment1.Connection1.Open
   DataEnvironment1.Command1 sDate
   'DataReport1.Orientation = rptOrientLandscape
  DataReport1.Orientation = rptOrientLandscape
DataReport1.Show
       DataReport1.PrintReport True, rptRangeAllPages
End Sub

Im using this SQL statement in DataEnvironments command1 properties.
SELECT flt, consignee, donumber, awbnumber, pkg, weight, examofficer, recname, remarks, `user`, serial, type, dodate FROM courier WHERE (dodate = ?)

Parameter Properties

Name: Param1
Direction :Input
Datatype : adDate

host data type :Date(VT_DATE)

This method works to filter by one date.
I couldnt figure out a way to filter it by two dates!!!!

THANX

0
Comment
Question by:jiyad
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 71

Expert Comment

by:Éric Moreau
ID: 12429444
0
 
LVL 1

Expert Comment

by:Programmer_Jeff
ID: 12430194
A possiblility (not a guarantee) is add another variable.  After your dodate variable:
dodate, dodate2 FROM courier WHERE (dodate = ? OR dodate2 = ?)

Good luck.
0
 
LVL 3

Expert Comment

by:georg74
ID: 12434974
I assume you want to get records with sDate <= dodate <= sDate2
you have to change following:

add Text2 field which will contain the second date

add these lines to the code after similar lines with sDate:

-    sDate2 = Format(CDate(Text2), "mm-dd-yyyy")

-    DataEnvironment1.Command2 sDate2

change the MsgBox statement to MsgBox "From " & sDate & " to " & sDate2

change the SQL statement to following:

SELECT flt, consignee, donumber, awbnumber, pkg, weight, examofficer, recname, remarks, `user`, serial, type, dodate FROM courier WHERE dodate >= ? AND dodate <= ?

HTH,
g.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 3

Expert Comment

by:georg74
ID: 12434994
... + you need a second Parameter of the same type as the first one
0
 

Author Comment

by:jiyad
ID: 12439929

thanx for the help georg
thanx for the help emoreau

im checking on it!!!!
0
 

Author Comment

by:jiyad
ID: 12440065
emoreau:

Ive checked the following link..


http://support.microsoft.com/default.aspx?scid=kb;en-us;244779

could you pls show me a way to filter between two dates using this method in the article( Parameterized DataReport)

thanks.
0
 
LVL 71

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 12442833
CommandText: Select * From Employees Where HireDate Between ? AND ?

Create a second parameters (pDate2)

.Command1 CDate(Text1.Text, Text2.text)
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question