Results 1 to 5 of 5

Thread: Date1 > Date2 then add date1

  1. #1

    Thread Starter
    Lively Member internet_wiz's Avatar
    Join Date
    Nov 2001
    Location
    Gonagbango
    Posts
    91

    Date1 > Date2 then add date1

    Hello
    I got this frekin problem with my code i kept changing it again and agian i tried different ways also but always got the same problem "err no 3021 either bof or eof is true or record has been deleted"

    i got 2 recordsets open with a date filed
    Find the smaller date between the 2 record sets then add it to listview keep looping untill all the fields are added

    basicly im trying to put the date in Desending order

  2. #2
    Lively Member
    Join Date
    Jun 2003
    Posts
    114
    Are you testing for the recordset returning an actual recordset?

  3. #3
    Fanatic Member
    Join Date
    Jun 2003
    Location
    IL
    Posts
    739
    I am pretty sure that the amount of records you have in both your recordset are not equal. So when you are looping through it, one of the recordset runs out of records and you are still trying to loop through it. The best way to do this is put a break point in your code and see where it errors. You can also check how many records you have in each recordset by looking at the RecordCount property for the recordset.
    Motto: Anything for a laugh.

    Getting second place only means you are the first loser to cross the finish line.

  4. #4

    Thread Starter
    Lively Member internet_wiz's Avatar
    Join Date
    Nov 2001
    Location
    Gonagbango
    Posts
    91
    Here is my freakin code
    VB Code:
    1. TotRsCount = Rs.RecordCount + Sales_Rs.Recourdcount
    2. Do untill i = TotRsCount
    3.     'MsgBox P_Date & "   " & S_Date & "    Loop No: " & i
    4.     If P_Date > S_Date Then
    5.       If RS.EOF = False Then
    6.         lblRemark = i
    7.         Set Itmx = lvDetail.ListItems.Add
    8.         Itmx.Text = RS("TransID")
    9.         Itmx.SubItems(1) = RS("InvoiceNo")
    10.         Itmx.SubItems(2) = RS("PartyID")
    11.         Itmx.SubItems(3) = RS("Qty")
    12.         'Itmx.SubItems(4) =
    13.         Itmx.SubItems(5) = RS("Amount")
    14.         Itmx.SubItems(6) = RS("P_Date")
    15.         Itmx.SubItems(7) = RS("Date_Time")
    16.       End If
    17.      
    18.       If Not RS.EOF = True Then
    19.     RS.MoveNext
    20.     P_Date = RS("P_Date")
    21.     i = i + 1
    22.       End If
    23.     End If
    24.    
    25.     If S_Date > P_Date Then
    26.       If Sales_Rs.EOF = False Then
    27.         lblRemark = i
    28.         Set Itmx = lvDetail.ListItems.Add
    29.         Itmx.Text = Sales_Rs("TransID")
    30.         Itmx.SubItems(1) = Sales_Rs("InvoiceNo")
    31.         Itmx.SubItems(2) = Sales_Rs("CsID")
    32.         Itmx.SubItems(3) = Sales_Rs("Qty")
    33.         Itmx.SubItems(4) = Sales_Rs("SP") & "(" & Sales_Rs("Discount") & ")"
    34.         Itmx.SubItems(5) = Sales_Rs("Amount")
    35.         Itmx.SubItems(6) = Sales_Rs("S_Date")
    36.         Itmx.SubItems(7) = RS("Date_Time")
    37.       End If
    38.      
    39.       If Not Sales_Rs.EOF = True Then
    40.     Sales_Rs.MoveNext
    41.     S_Date = Sales_Rs("S_Date")
    42.     i= i + 1 '
    43.       End If
    44.     End If
    45.    
    46.     ChkLoop = ChkLoop + 1 ' StoP Loop if chkloop is more than     TotRsCount
    47.     'MsgBox "ChkLoop: " & ChkLoop & "    LoopNo :" & i
    48.     If ChkLoop > TotRsCount Then
    49.       MsgBox "i= " & i & "         ChkLoop = " & ChkLoop
    50.       Exit For
    51.     End If
    52.  
    53.  Loop
    Last edited by internet_wiz; Feb 16th, 2004 at 09:32 PM.

  5. #5

    Thread Starter
    Lively Member internet_wiz's Avatar
    Join Date
    Nov 2001
    Location
    Gonagbango
    Posts
    91
    Any ideas??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width