【问题标题】:Missing first record DAO access缺少第一条记录 DAO 访问权限
【发布时间】:2014-11-14 03:32:46
【问题描述】:

我有这个代码:

If Len(Me.Text9.Value & vbNullString) = 0 Then
      sSQL = "SELECT [Ra 1080] as [civil] FROM civil where main=" & Forms![PDS Main Form]![Main Table ID] & " ORDER BY ID"
      Set rs = db.OpenRecordset(sSQL)
      rs.MoveFirst
           Do Until rs.EOF
              Text9.Value = Text9.Value + rs!civil + ", "
           rs.MoveNext
           Loop
           Set rs = Nothing
           End If 

如果您运行查询,它将返回 3 条记录 cs1.5,cs1.3,cs1.9

运行文本框的代码只会返回 cs 1.3, cs 1.9,

【问题讨论】:

    标签: ms-access vba dao


    【解决方案1】:

    不确定使用 MoveFirst 是否会导致问题,请尝试此代码。看看它是否有效。

    If Len(Me.Text9.Value & vbNullString) = 0 Then
        sSQL = "SELECT [Ra 1080] As [civil] FROM civil WHERE main = " & _
                Forms![PDS Main Form]![Main Table ID] & " ORDER BY ID"
        Set rs = db.OpenRecordset(sSQL)
    
        Do While Not rs.EOF
            Text9.Value = Text9.Value & rs!civil & ", "
            rs.MoveNext
        Loop
    
        Set rs = Nothing
    End If 
    

    只是去掉了 .MoveFirst 和其他一些简单的修改。

    【讨论】:

      猜你喜欢
      • 2021-11-29
      • 2021-01-20
      • 2021-12-18
      • 1970-01-01
      • 2020-09-07
      • 2014-11-23
      • 2019-10-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多