Click here to Skip to main content
15,884,041 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Respected Sir,
I am making a sofware in vb 6.0. I am making a Filter Form.
in this software. problem is when i am enter date range in textbox when i am enter date and click on ok button then it give error 3021 either bof or eof is true or current record is deleted.
but when i am enter any reciept number in range of a textbox it should not give any error and show the result.

code:---

Public Sub getconnection()
Set getcon = New ADODB.Connection
getcon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\DAK.mdb"
End Sub

Public Sub getrecord()
    getconnection
    getcon.Open
    Dim fatchrecord
    Set rsrecord = New ADODB.Recordset
 
    If Option6.Value = True Then
'        If Text3.Text = "" Or Text4.Text = "" Then
'            MsgBox ("Please Enter Date")
'            Exit Sub
'        Else
        fatchrecord = "SELECT DAK.RecptNo, DAK.RecptDt, DAK.Type, DAK.FromWhom, DAK.Name, DAK.Address, DAK.AddressTo, DAK.Sender, DAK.SenderNo, DAK.SenderDt, DAK.Subject, DAK.BriefCon, DAK.MarkTo, DAK.MarkDt, DAK.Remarks, DAK.Action, DAK.tdate, Type.Type_desc, From.From_Desc, From.From_Desig, From.From_Add, MarkTo.Mark_desc, Action.Action FROM (((DAK INNER JOIN [Action] ON DAK.Action = Action.ActionId) INNER JOIN MarkTo ON DAK.MarkTo = MarkTo.Mark_id) INNER JOIN Type ON DAK.Type = Type.Type_id) INNER JOIN [From] ON DAK.FromWhom = From.From_id Where Dak.RecptDt>=" & CDate(Text3.Text) & " and Dak.RecptDt<=" & CDate(Text4.Text) & ""
'        End If
    End If
If Option5.Value = True Then
    fatchrecord = "SELECT DAK.RecptNo, DAK.RecptDt, DAK.Type, DAK.FromWhom, DAK.Name, DAK.Address, DAK.AddressTo, DAK.Sender, DAK.SenderNo, DAK.SenderDt, DAK.Subject, DAK.BriefCon, DAK.MarkTo, DAK.MarkDt, DAK.Remarks, DAK.Action, DAK.tdate, Type.Type_desc, From.From_Desc, From.From_Desig, From.From_Add, MarkTo.Mark_desc, Action.Action FROM (((DAK INNER JOIN [Action] ON DAK.Action = Action.ActionId) INNER JOIN MarkTo ON DAK.MarkTo = MarkTo.Mark_id) INNER JOIN Type ON DAK.Type = Type.Type_id) INNER JOIN [From] ON DAK.FromWhom = From.From_id Where Dak.RecptNo>=" & Val(Text1.Text) & " and Dak.RecptNo<=" & Val(Text2.Text) & ""
    End If 
    
"select * from dak"
    Set rsrecord.ActiveConnection = getcon
    rsrecord.Open fatchrecord, getcon, adOpenDynamic, adLockOptimistic
   ' On Error Resume Next
   
   rsrecord.MoveLast 
------------------- give error when i am enter date in search box

but when i am enter number then is give no error
Please Give the me soultion fast becuase it is urgent becuase this software is running after 2 day in a company.
Please Plz give me solution
Posted
Updated 11-May-22 7:16am
v2

1 solution

It most likely means that your query with a date parameter is returning no records.

Before you use the RecordSet you should do a check for no records.

If Not rs.BOF Adn rs.EOF Then

'Your code here

End If


You might need to add quotes around the date value
Dak.RecptDt<=""" & CDate(Text4.Text) & """"
 
Share this answer
 
v2

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