2
我試圖輸出所有鏈接表的名稱,包括它們的日期/時間字段以及那些字段值。鏈接表和Ms Access的錯誤(運行時錯誤'3622':dbSeeChanges/Identity列)
下面的代碼可輸出的第一個表,字段名和他們的第一個值,不是所有的價值,儘管當它到達下一個鏈接表,我得到這個錯誤
Run-time Error '3622'
You must use the dbSeeChanges option with OpenRecordSet when accessing a SQL Server table that has an IDENTITY column.
這裏是我的代碼
Private Sub btnGetFields_Click()
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim f As Field
Dim rst As DAO.Recordset
Dim numField As Integer
Set db = CurrentDb
For Each tdf In db.TableDefs
If Left$(tdf.Connect, 9) = "ODBC;DSN=" Then
Set rst = CurrentDb.OpenRecordset(tdf.Name)
numField = rst.Fields.Count
Debug.Print "Table: " & tdf.Name
For index = 0 To numField - 1
If rst.Fields(index).Type = dbDate Then
Debug.Print "Field: " & rst.Fields(index).Name; " Value : "; rst.Fields(index).Value
End If
Next
End If
Next
Set tdf = Nothing
Set db = Nothing
End Sub
我讀過的東西,如果我使用SQL表我應該使用ADO? 任何想法?
就是這樣!謝謝你,先生! –