问题描述
最新更新(周一晚上)
首先,我成功地显示并从我的 city_table 中选择,填充表格上的city_no
First, I successfully display and select from my city_table, populating thecity_no on the form
然后我尝试使用该值来提取/使用 city_nm 和state_nm 相同的形式.
I am then attempting to use that value to extract/use the city_nm andstate_nm on the same form.
我将其编码为 city_no 的(修改后的)更新后代码.
I coded this as the (modified) afterupdate code for city_no.
Private Sub city_no_AfterUpdate()
Dim got_city_nm, got_state_nm
got_city_nm = DLookup("[city_nm]", "city_table", "[city_no]" = "city_no")
got_city_nm = DLookup("city_nm", "city_table", "city_no='" & Me.city_no & "'")
city_nm = got_city_nm
got_state_nm = DLookup("[state_nm]", "city_table", "[city_no]" = "city_no")
got_state_nm = DLookup("state_nm", "city_table", "city_no='" & Me.city_no & "'")
state_nm = got_state_nm
seat_no = "XXX"
End Sub
仍然没有任何反应,包括最后一条语句(将XXX"分配给seat_no)
Still nothing happens including the last statement (assigning "XXX" to seat_no)
所以我将其简化为自己尝试:
So I simplified it to just try that by itself:
Private Sub city_no_AfterUpdate()
seat_no = "XXX"
End Sub
还是没有.我显然遗漏了一些简单而琐碎的东西.
Still nothing. I'm clearly missing something simple and trivial.
推荐答案
将 City Name 文本框的 RecordSource
属性设置为:
Set the RecordSource
property of the City Name textbox to:
=DLookup("[city_nm]", "city_table", "[city_no]" = "city_no")
.
然后将 State Name 文本框的 RecordSource
属性设置为:
Then set the RecordSource
property of the State Name textbox to:
=DLookup("[state_nm]", "city_table", "[city_no]" = "city_no")
这篇关于在 ms 访问中尝试使用一个字段来填充表单中的其他字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!