MSACCESS - 填充文本框与查询值 [英] MSAccess - populate text box with value from query
问题描述
我有一个窗体上的组合框和几个文本框。当我选择从组合框中的值,我希望它运行基于该值的查询和查询返回的数据填充的文本框。查询应只返回一个记录和文本框correnspond不同列的记录。
I have a combo box and several text boxes on a form. When I select a value from the combo box I want it to run a query based on that value and populate the text boxes with the data returned by the query. The query should only return one record and the textboxes correnspond to different columns in that record.
我有这个code:
Private Sub cbo_equip_loc_Change()
Dim location As String
Me.cbo_equip_loc.SetFocus
location = DLookup("NAME", "Query1", "position = '" & Me.cbo_equip_loc.SelText & "'")
Me.Text51.SetFocus
Me.Text51.Text = location
End Sub
不过,我得到这个错误:该属性是只读的,不能将
But I get this error: "This property is read-only and can't be set"
任何想法?
解决:IM白痴。
我在控件来源的东西,我试图做一些之前的价值。删除这一点,它的工作!
I had some value in the Control Source from something I was trying to do before. Removed that and it worked!
推荐答案
文本框的 Text51 已被锁定,设置属性锁定为False。
Textbox Text51 is locked, set property Locked to False.
这篇关于MSACCESS - 填充文本框与查询值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!