m_strSql = " select 客户ID as ID , 公司名称 as Name"
    m_strSql = m_strSql & " from 客户表 "
    m_strSql = m_strSql & " where 逻辑删除标志位='0'"
    Set mDS_Recordset = Nothing
    mDS_Recordset.Open m_strSql, gobjDatabase, adOpenStatic, adLockReadOnly, adCmdText
     m_strSql = " select 客户ID as ID , 公司名称 as Name"
    m_strSql = m_strSql & " from 客户表 "
    m_strSql = m_strSql & " where 逻辑删除标志位='0'"
    Set mDS_Recordset = Nothing
    mDS_Recordset.Open m_strSql, gobjDatabase, adOpenStatic, adLockReadOnly, adCmdText
    Do While Not mDS_Recordset.EOF
        m_strSql = " select 客户ID as ID , 公司名称 as Name"
        m_strSql = m_strSql & " from 客户表 "
        m_strSql = m_strSql & " where 逻辑删除标志位='0'"
        Set rs = Nothing
        
        rs.Open m_strSql, gobjDatabase, gobjDatabase, adOpenStatic, adLockReadOnly, adCmdText
        If rs.RecordCount > 0 Then
            MsgBox (rs!Id)
        End If
        mDS_Recordset.MoveNext
    Loop

解决方案 »

  1.   

    我看是SQL语句出问题,SQL的别名不用AS而直接用空格就行了
      

  2.   

    问出在rs.Open m_strSql, gobjDatabase, gobjDatabase, adOpenStatic, adLockReadOnly, adCmdText
    这行,另的地方用了没有问题
      

  3.   

    Set rs = Nothing   <--------  是这一行的问题,你把Rs对象给释放了!!
            
            rs.Open m_strSql, gobjDatabase, gobjDatabase, adOpenStatic, adLockReadOnly, adCmdText