2

我正在尝试使用 For 循环遍历单个记录记录集中的字段以填充表单上的字段。我希望找到一种比输入六行 txtField.value = rs!Field 更简洁/可重复使用的方法。

当我在运行时查看代码时,两个变量都包含正确的信息,只是没有在表单上显示它们。任何帮助将不胜感激。

Dim strClient As String
Dim rsClient As dao.Recordset
Dim tfield As String
Dim ffiend As String
Dim fld As dao.Field

Set dbs_Current = CurrentDb()

strClient = "Select * from tblClient where pk_client_id = " & gbl_Client_ID

Set rsClient = dbs_Current.OpenRecordset(strClient)

For Each fld In rsClient.Fields
    On Error Resume Next
    tfield = "txt" & fld.Name & ".value"
    ffield = "rsClient!" & fld.Name
    tfield = ffield

Next fld
4

0 回答 0