标题:实时错误“3021”BOF或EOF中有一个是“真”,或者当前的记录已被删除
取消只看楼主
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
结帖率:84.62%
已结贴  问题点数:20 回复次数:1 
实时错误“3021”BOF或EOF中有一个是“真”,或者当前的记录已被删除
请看如下代码:

Option Explicit
   
Private conn As ADODB.Connection

Private Rst As New ADODB.Recordset
Private Sub Combo1_Click()
If Combo1.Text = "支出" Then
         Rst.Fields("b") = Combo1.Text
         Combo2.Clear
         Combo2.AddItem "日常支出"
         Combo2.AddItem "其他支出"

         Combo2.Text = Combo2.List(0)
End If

If Combo1.Text = "收入" Then
Rst.Fields("a") = Combo1.Text
Combo2.Clear
Combo2.AddItem "上班收入"
Combo2.AddItem "其他收入"

Combo2.Text = Combo2.List(0)

执行后,出现如下对话框:

实时错误“3021”

BOF或EOF中有一个是“真”,或者当前的记录已被删除。。。。。。。
搜索更多相关主题的帖子: 记录 上班 
2014-12-12 16:41
lijun337
Rank: 1
等 级:新手上路
帖 子:379
专家分:5
注 册:2006-4-12
得分:0 
可能是我的db1.mdb里面的db01里面的没有数据

我试着在form_load()里面添加如下代码:

Private Sub Form_Load()


    Dim ConString As String
    ConString = "Provider=Microsoft.Jet.OleDb.4.0;Persist Security Info = False;" _
               & "Data Source =" & App.Path & "\db1.mdb;Jet OleDb:"

   
    Set conn = CreateObject("ADODB.Connection")
    With conn
        .ConnectionString = ConString
        .Open
    End With
   
    Label1.Caption = Now
Text3.Text = Year(Date)
Text4.Text = Month(Date)
Text5.Text = Day(Date)


    Rst.CursorLocation = adUseClient
    Rst.Open "Select * From db01", conn, adOpenKeyset, adLockPessimistic, adCmdText
   
    If Rst.RecordCount > 0 Then
   
    Text1.Text = Rst.Fields("jr").Value & ""
    Text2.Text = Rst.Fields("bz").Value & ""
Rst.Fields("n") = Text3.Text
Rst.Fields("y") = Text4.Text
Rst.Fields("r") = Text5.Text


    Else
   
   
End If
Text4.ForeColor = RGB(0, 0, 150)
Text5.ForeColor = RGB(0, 0, 150)
End Sub
2014-12-12 17:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-439867-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.116765 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved