2 Replies - 222 Views - Last Post: 02 October 2019 - 11:14 AM Rate Topic: -----

#1 rushi61   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-September 19

the datagrid is show wrong output in vb6

Posted 02 October 2019 - 01:27 AM

when i choose same date from month 10(say dtpckr1 = 02-10-2019 and dtpckr2 = 02-10-2019 ) ..data datagrid does not print anything and shows the msgbox not record found which i code for convinence...but when i choose start date from last moth and end date in this month(say dtpckr1 = 30-09-2019 and dtpckr2 = 02-10-2019 ) it shows all the data from month 09 and nothing from month 10 ... and the strange this is when choose date which is from moth 09 even if it is same(say dtpckr1 = 13-09-2019 and dtpckr2 = 13-09-2019 or 22-09-2019) it works perfectly i tried to attach screen shots but ..it showing server error...so please try to help me out by refering the following code .. thanks

Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset

Private Sub cmdSearch_Click()

Dim date1 As Date
Dim date2 As Date

If IsNull(DTPicker1.Value And DTPicker2.Value) Then
    MsgBox "You must select date", vbCritical, "Warning"
    Exit Sub
End If
DTPicker1.Value = Format(DTPicker1.Value, "dd-mm-yyyy")
DTPicker2.Value = Format(DTPicker2.Value, "dd-mm-yyyy")
date1 = DTPicker1.Value
date2 = DTPicker2.Value
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\OrderMania\ordermania.mdb;Persist Security Info=False"
rs.CursorLocation = adUseClient



If DTPicker2.Value < DTPicker1.Value Then
MsgBox "End Date Cannot Be Lesser Then Start Date", vbCritical, "Wrong Input"
Exit Sub
Else
Adodc1.RecordSource = "select * from order1 where (CDate(date) between #" & date1 & "# and #" & DTPicker2.Value & "#)"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "Please Enter Another Date", vbCritical, "No Record Found"
Else
Adodc1.Caption = Adodc1.RecordSource
End If
End If

con.Close

Call sale


End Sub


Public Sub sale()
Dim i As Integer
Dim Tot, gst, gtot As Double
For i = 0 To Adodc1.Recordset.RecordCount - 1
    Tot = Tot + CDbl(DataGrid1.Columns(5).Text)
    Adodc1.Recordset.MoveNext
Next i
    
Text1.Text = Tot
gst = Tot * 0.05
Text2.Text = gst
gtot = Tot + gst
Text3.Text = gtot

End Sub




Is This A Good Question/Topic? 0
  • +

Replies To: the datagrid is show wrong output in vb6

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15300
  • View blog
  • Posts: 61,364
  • Joined: 12-June 08

Re: the datagrid is show wrong output in vb6

Posted 02 October 2019 - 06:27 AM

Easy first step - is your date formats in the Access DB the same format as what you are attempting to search?
Was This Post Helpful? 0
  • +
  • -

#3 rushi61   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-September 19

Re: the datagrid is show wrong output in vb6

Posted 02 October 2019 - 11:14 AM

View Postmodi123_1, on 02 October 2019 - 06:57 PM, said:

Easy first step - is your date formats in the Access DB the same format as what you are attempting to search?



yes... i checked it... its a same format dd-mm-yyyy...infact when i created the database i kept it in mind...the data type is "date/time" and format is "short date"
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1