Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB
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.
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
DTPicker1.Value = Format(Now, "DD-MM-YYYY")
DTPicker2.Value = Format(Now, "DD-MM-YYYY")
Posted 2-Jan-13 17:06pm
Edited 4-Jan-13 4:11am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 ?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Dear friends
I have used the following query and i think that has solved the problem.
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
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100