1
我有一個包含多個字段的訪問表。我想通讀所有行,所有字段,如果該字段包含NULL,請設置默認值「」。我正嘗試使用字段定義來讀取表格,但無法找到該字段的現有值。當您不知道字段名稱時將Access表字段設置爲值
Dim fld As DAO.Field
Dim t As DAO.TableDef
Dim fldVal as string (test variable to see if I can find value of field)
For Each t In cd.TableDefs
If t.Name = "PERSONS" Then
For Each fld In t.Fields
Just trying to find the existing value here
fldVal = fld.Value
If fld.Type = 10 And IsNull(fld) = True Then
fld.Value = ""
End If
Next
End If
Next
問題出在哪裏?錯誤信息?如果是這樣,哪一行觸發它? – HansUp
在線fldVal = fld.value我得到一個錯誤:3219無效的操作 – Lele
如果你把Dim fldVal作爲字符串,那麼你不能給它賦一個Null值。嘗試'Dim fldVal As Variant'。 –