这是我尝试过的。这种语法有什么问题。当我运行此代码时,在combo52中选择一个值后,我得到一个参数值错误消息。
Private Sub Combo52_AfterUpdate()
With Forms("UserForm").Combo56
If IsNull(Forms("UserForm").Combo52) Then
.RowSource = ""
Else
.RowSource = "SELECT [PayGroupCountryDesc] " & _
"FROM HRBI " & _
"WHERE [PayGroupRegionCode]=" & Forms("UserForm").Combo52
End If
Call .Requery
End With
End Sub
答案 0 :(得分:0)
要在查询中访问表单字段的值,您应该使用感叹号(!)作为分隔符而不是点(。),并且应该在名称前添加[Forms]
:
.RowSource = "SELECT [PayGroupCountryDesc] " & _
"FROM HRBI " & _
"WHERE [PayGroupRegionCode]=[Forms]![UserForm]![Combo52];"