如何获取ADODB记录集的名称属性?

时间:2015-05-12 22:07:59

标签: vba ms-access access-vba

如何在VBA中获取ADODB记录集的名称? DAO有一个.Name属性,但ADODB似乎没有。

起初我认为没有这样的财产,但现在,我认为必须有。

如果以编程方式设置表单的记录集,然后关闭并保存表单而不将记录集属性设置为空,则将使用您打开的记录集的名称填写表单recordsource属性。

示例:

我像这样设置记录集

Set Me.Recordset = oDal.OpenRecordset("tblOptionList")

如果我不这样做

Set Me.Recordset = Nothing

tblOptionList将位于表单recordsource属性

这是我打开Recordsets的功能

Public Function OpenRecordset(ByVal Tablename As String) As         ADODB.Recordset
    Dim FilePath As String
    Dim rs As ADODB.Recordset

    Set rs = New ADODB.Recordset

    rs.CursorLocation = adUseClient

    FilePath = GetFilePath(Tablename)

    'Try to get a connection
    Connection

    If ConnOpen Then
        Set rs.ActiveConnection = pDbConn
        rs.CursorType = adOpenKeyset
        rs.LockType = adLockOptimistic
        rs.Open Tablename

        If pEnableOffline Then
            SaveOffline rs, Tablename
        End If
    Else
        'No connection, check for offline availablility

        If Dir(FilePath) <> "" And pEnableOffline Then
            rs.Open FilePath
        Else
            MsgBox "No Offline data and Server is Unavailable"
            Exit Function
        End If
    End If

    Set OpenRecordset = rs

End Function

1 个答案:

答案 0 :(得分:0)

The wget -P /path/to/save -H -r -nc -l2 -A".jpg,.JPG" -erobots=off "http://myurl.com/out.php?t=1.0.0.1&url=http://myurl.com/path/Dir of File&fc=1&p=100" property is the counterpart to the ADODB.Recordset.Source property.

If the recordset's data source is a table or saved query, those properties will give you its name. If the data source is a DAO.Recordset.Name statement, those properties will show you the statement text.