尝试从表'Invoices‘的最新记录中获取整数( RecieptNumber ),以将值存储在变量invoiceNum (integer)中。
Dim rstInvoices As Recordset
Set cdCurrentDatabase = CurrentDb
Set rstInvoices = cdCurrentDatabase.OpenRecordset("SELECT LAST ([RecieptNumber]) FROM Invoices;")
invoiceNum = rstInvoices("[RecieptNumber]").Value昨天开始VBA编程,所以感谢任何帮助,我将能够理解。
发布于 2014-12-11 07:13:06
rstInvoices的字符串参数必须引用通过执行Select语句实际返回的字段。但是查询返回的不是字段RecieptNumber,而是没有指定名称的Last(RecieptNumber)。因此,您首先需要使用AS子句为该聚合列命名:
SELECT LAST(RecieptNumber) AS LastNumber ...现在,您可以在VBA中引用该字段:
invoiceNum = rstInvoices("[LastNumber]").Valuehttps://stackoverflow.com/questions/27412372
复制相似问题