我正在尝试使用For循环遍历单个记录记录集中的字段以填充表单上的字段。我希望找到一种更整洁/可重复使用的方法,而不是输入6行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