【发布时间】:2013-08-02 16:15:30
【问题描述】:
我有一个包含多个字段的访问表。我想通读所有行、所有字段,如果该字段包含 NULL,则设置默认值“”。我正在尝试使用字段定义通读该表,但无法找到该字段的现有值。
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
【问题讨论】:
-
问题出在哪里?错误信息?如果是这样,哪一行会触发它?
-
在线 fldVal = fld.value 我得到一个错误:3219 Invalid operation
-
如果您
Dim fldVal As String则无法为其分配Null值。试试Dim fldVal As Variant。 -
我将 def 更改为变体,但仍然无法正常工作。如果我只是尝试使用 fldVal = fld.name 获取字段名称,它工作正常。
-
我需要先阅读表格吗?也许它没有显示实际的数据值,因为我没有读入记录。