Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Dear friends
How are you all.First of all a very happy and prosperous new year to all of you.
Friends
My project was actually printing reports in vb6 and access nicely till 31 of December 2012. But now all the records i am saving in the database on a particular day is not being shown in the reports on that day by using Datetime Picker in VB6.
Actually when i use the Do While Not rs.EOF code it always comes true and control goes to the code outside while loop.
I want to use dtpicker using any format of date so that my reports gets the result

The code is as under.
VB
Connection
sql = "patients"
Set rs = New ADODB.Recordset

rs.Open "select * from patients where date between #" & DTPicker1.Value & "# AND #" & DTPicker2.Value & "# ", Con, adOpenDynamic, adLockPessimistic

        Dim X As Integer
Do While Not rs.EOF

  X = X + rs.Fields(9).Value ' here field 9 is actually the rate field

  rs.MoveNext
Loop

   DataReport1.Sections("Section5").Controls("label17").Caption = X
        Set DataReport1.DataSource = rs
        DataReport1.Show vbModal



Also i have formated the datatime picker value as under
VB
DTPicker1.Value = Format(Now, "DD-MM-YYYY")
DTPicker2.Value = Format(Now, "DD-MM-YYYY")
Posted
Updated 4-Jan-13 4:11am
v2

Given that VB6 was obsolete a decade ago, perhaps the date time picker in there can't go past 2012 ? I hope so, then that foul language will finally die.

Have you debugged to see what value is being passed through ?
 
Share this answer
 
Dear friends
I have used the following query and i think that has solved the problem.
VB
Connection
sql = "patients"
Set rs = New ADODB.Recordset

'rs.Open "select * from patients where date between #" & DTPicker1.Value & "# AND #" & DTPicker2.Value & "# ", Con, adOpenDynamic, adLockPessimistic
rs.Open "select * from patients where date between #" & Format$(DTPicker1.Value, "mm/dd/yyyy") & "# AND #" & Format$(DTPicker2.Value, "mm/dd/yyyy") & "# ", Con, adOpenDynamic, adLockPessimistic

        Dim X As Integer
Do While Not rs.EOF

  X = X + rs.Fields(9).Value

  rs.MoveNext
Loop

   DataReport1.Sections("Section5").Controls("label17").Caption = X
        Set DataReport1.DataSource = rs
        DataReport1.Show vbModal



Thank you
Sarfaraz
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900