我正在尝试使用组合框链接子表单,我编写了以下代码

时间:2019-01-09 11:02:47

标签: ms-access-2016

Dim mydrawing As String 
mydrawing = "select * from tbl_welddata  where([Drawingno] = " & Me!CboDrawingno & ")" 
Me.tbl_welddatasubform.Form.RecordSource = mydrawing Me.tbl_welddatasubform.Form.Requery

我收到一条错误消息;

  

数据类型不匹配错误3464

每次调试时都指向此行

Me.tbl_welddatasubform.Form.RecordSource = mydrawing

有人可以帮我排序吗?

1 个答案:

答案 0 :(得分:0)

放入调试行,然后研究输出:

Dim mydrawing As String 

mydrawing = "select * from tbl_welddata where([Drawingno] = " & Me!CboDrawingno & ")" 
' If text, quotes are needed:
' mydrawing = "select * from tbl_welddata where([Drawingno] = '" & Me!CboDrawingno & "')" 
Debug.Print mydrawing

Me!tbl_welddatasubform.Form.RecordSource = mydrawing

不需要重新查询。

您可以手动应用生成的 mydrawing 吗?

Drawingno 是数字,不是文本吗?

tbl_welddatasubform 是子表单 control 的名称吗?