我正在尝试对文本框搜索系统进行编码,但遇到运行时错误3075。
表单的记录源是来自查询的SQL语句
我用过的下面的代码中包含相同的SQL语句,我添加了WHERE
和OR
。
Private Sub btnSearch_Click()
Dim SQL As String
SQL = "SELECT Products.ProdID, categories.CatName, Makes.MakeName, Products.ProdModel, Products.ProdDesc, Suppliers.SuppName, ProdType.TypeName, Colours.ColName, Size.SizeName, Products.DateAdded, Products.ProdBarcode" _
& "FROM Suppliers RIGHT JOIN (categories RIGHT JOIN (ProdType RIGHT JOIN (Makes RIGHT JOIN ((Colours RIGHT JOIN Products ON Colours.ColourID = Products.ColourID) LEFT JOIN [Size] ON Products.SizeID = Size.SizeID) ON Makes.MakeID = Products.ProdMake) ON ProdType.TypeID = Products.ProdTypeID) ON categories.CatID = Products.ProdCategory) ON Suppliers.SuppID = Products.SupplierID" _
& "WHERE (((Products.ProdModel) Like '*" & Me.txtSearch & "*'))" _
& "Or (((Products.ProdBarcode) Like '*" & Me.txtSearch & "*'))" _
& "ORDER BY categories.CatName;"
Me.Form.RecordSource = SQL
End Sub
如果有人能指出我正确的方向,我将不胜感激。