将 VBA 代码转换为表单 TextBox 的控件源
我认为这是一个简单的答案,但我只是不擅长 SQL 语句和子查询(如果这是我需要的)。 我有一个按钮,它以连续形式 (me.ProdNum) 从记录中获取值并获取记录集。它在 MsgBox 中显示该记录集的结果(为简单起见,删除了代码)。
目标:我想在文本框中的每条记录上报告“totalsupp.recordset”。
我假设我需要一个 SELECT COUNT(subquery),但我无法获得正确的语法。 [PNUM] 和 ProdNum 是字符串
Private Sub MultSupp_Click()
Dim db As DAO.Database
Dim totalsupp As DAO.Recordset
Set db = CurrentDb
Set totalsupp = db.OpenRecordset("SELECT * FROM qryKANBAN_Suppliers WHERE [PNUM] = '" & Me.ProdNum & "'")
Debug.Print totalsupp.RecordCount
Set totalsup = Nothing
End Sub
I assume this is an easy answer but I am just not good at SQL statements and subqueries (if that's what I need).
I have a button that takes a value from a record in a continuous form (me.ProdNum) and gets a recordset. It displays the results of that record set in a MsgBox (code removed for simplicity).
Objective: I'd like to report "totalsupp.recordset" on each record in a textbox.
I assume I need a SELECT COUNT(subquery), but I can't get the syntax correct. [PNUM] and ProdNum are strings
Private Sub MultSupp_Click()
Dim db As DAO.Database
Dim totalsupp As DAO.Recordset
Set db = CurrentDb
Set totalsupp = db.OpenRecordset("SELECT * FROM qryKANBAN_Suppliers WHERE [PNUM] = '" & Me.ProdNum & "'")
Debug.Print totalsupp.RecordCount
Set totalsup = Nothing
End Sub
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢有关使用 DCount 的评论中的帮助。我对所有双引号和单引号感到非常困惑......
Thanks to the help in the comments about using DCount. I get so confused about all the double quotes and single quotes...