Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB
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 18-Jan-10 0:49am
Edited 18-Jan-10 4:45am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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) & """"
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 370
1 Prakriti Goyal 177
2 Sergey Alexandrovich Kryukov 155
3 jlopez788 134
4 _Amy 110
0 OriginalGriff 6,762
1 Sergey Alexandrovich Kryukov 5,539
2 Maciej Los 3,479
3 Peter Leow 3,323
4 DamithSL 2,505


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 18 Jan 2010
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