所以我有一堆表都链接在一起或者另一个,我正在尝试制作一份报告,列出所选发票号码范围内的所有项目,并开始流程,用户将点击一个按钮,该按钮将打开一个包含3个字段,FirstInvoiceNumber,LastInvoiceNumber和Client的弹出窗体。这些字段比保存用户输入的全局变量然后插入到Report_Open事件中的SQL语句中。有一个语法错误,但大约半小时后,我找到并修复它。但现在,我得到这个运行时错误2465,其中说“Microsoft Access无法找到字段'l1'(在1前面,它是一个我不知道如何键入的符号,但它看起来就像你的表达中提到的一个高大的小写字母L)。“ 也许我只是看这个太久了,但我能看到的唯一“1”是SQL语句有Initials字段的地方,而且它们都在括号内,所以我不确定是什么错。无论如何,这是荒谬的SQL (注意:我发现在一行上读取更容易,只是侧向滚动而不是将一个大块拆分成多行,所以这个SQL语句只适用于2行,我会增加一个段落空间,这样更容易找到它)
Me.RecordSource = "SELECT Invoices.InvNo,
Invoices.JobNo,
Invoices.InvDate,
Invoices.TimeTotal,
Invoices.Tax,
Invoices.POTotal,
Invoices.SubTotal,
Invoices.InvTotal,
Invoices.DatePaid,
Invoices.AmountPaid,
Invoices.Terms,
Contacts.EMail,
Invoices.Status,
' & 'Attn: ' & [FirstName] & ' ' & [LastName] & ' AS FullName,
Companies.CompanyFullName,
Companies.CompanyAbrv,
Contacts.Department,
' & [City] & ',
' & [State] & ' ' & [Zipcode] & ' AS AddressLine3,
Invoices.ClientPONo,
InvLineItems.LineItemNote,
InvLineItems.Adjustments,
InvLineItems.Status,
InvLineItems.Cost,
[Cost]+([Cost]*[Adjustments]) AS AAC,
' & [Contacts].[AddressLine1] & ',
' & [Contacts].[AddressLine2] & ' AS AddressLine1and2,
' & [Invoices].[InvNo] & '-' & [Invoices].[JobNo] & ' AS InvNoandJobNo,
Left([Contacts].[FirstName],
1) & Left([Contacts].[LastName],
1) AS Initials,
Jobs.JobTitle,
& ' & [Jobs].[JobTitle] & ' ' & [Jobs].[ClientCode] & ' AS Product,
InvLineItems.Requester,
Companies.CompanyID' _
& 'FROM ((((Invoices
LEFT JOIN (Contacts
RIGHT JOIN Jobs ON Contacts.ContactID = Jobs.ContactID) ON Invoices.JobNo = Jobs.JobNo)
LEFT JOIN InvLineItems ON Invoices.InvNo = InvLineItems.InvNo)
LEFT JOIN PurchaseOrders ON Invoices.InvNo = PurchaseOrders.InvNo)
LEFT JOIN POLineItems ON PurchaseOrders.PONo = POLineItems.PONo)
LEFT JOIN Companies ON Jobs.CompanyID = Companies.CompanyID'