由于我一遍又一遍地做同样的事情,我想编写一个通用函数,它传递调用函数的形式,另一个形式名称有一个带有值的字段。我的表单上的字段正在传递值,而字段则从另一个表单传递。我认为这应该很容易。
一个简单的例子:
call setdefaultvalues(form1 as object, form2 as object, field1 as object, field2 as object)
function setdefaultvalues(form1 as ojbect, form2 as object, field1 as object, field2 as object)
If CurrentProject.AllForms(form1).IsLoaded Then
form1.field1.defaultvalue = form2.field2
end if
end function
有人可以帮我一把。谢谢!
答案 0 :(得分:0)
这是传递对象名称的一种方法。然后参考......
Private Sub Command6_Click()
' Pass the names of the objects.
Call setdefaultvalues(Me.Name, Me.Name, "txtField1", "txtField2")
End Sub
Function setdefaultvalues(form1 As String, form2 As String, field1 As String, field2 As String)
If CurrentProject.AllForms(form1).IsLoaded Then
Forms(form1).Controls(field1).DefaultValue = Forms(form2).Controls(field2)
End If
End Function