[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-10-27
7
Medium Priority
?
2,013 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 70

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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 70

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Simple Linear Regression
Introduction to Processes

656 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