在Vb6.0运行时错误3021中,bof或eof为true [英] IN Vb6.0 runtime error 3021 either bof or eof is true

查看:256
本文介绍了在Vb6.0运行时错误3021中,bof或eof为true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生,
我正在vb 6.0中制作软件.我正在制作过滤器表格.
在此软件中.问题是当我输入日期并单击确定按钮时,我在文本框中输入日期范围时,它给出错误3021,要么bof或eof为true,要么当前记录被删除.
但是当我在文本框范围内输入任何接收号码时,它不应给出任何错误并显示结果.

代码:---

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 

-------------------当我在搜索框中输入日期时出现错误

但是当我输入数字时就没有错误
请紧急通知我,因为该软件在公司中运行2天后非常紧急.
请Plz给我解决方案

------------------- 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

推荐答案

这很可能意味着带有日期参数的查询未返回任何记录.

在使用RecordSet之前,应检查是否没有记录.

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


这篇关于在Vb6.0运行时错误3021中,bof或eof为true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆