访问2013错误3061

时间:2017-08-23 04:05:48

标签: sql ms-access multiple-tables

我的访问2013数据库中有四个表。客户,车辆,月度通票和收据。主键是CustomerID(字符串),VehicleiD(字符串)Serialnumber(自动编号)和ReceiptNo(自动编号)。 现在,我想在文本框中输入主键并单击命令按钮时显示表单上的字段。例如,当用户输入序列号时,我必须从客户表中检索客户名称,从车辆表中检索车辆ID,从月经表中检索到期日期,从收据表中检索收据号和总数。  我已经给出了下面的代码。当我运行此代码时,错误3061几个参数,预期发生1。我试着在田野周围和没有方括号。例如。车辆。[VehicleID]和Vehicle.VehicleID 代码:

Dim strSQL As String
 Dim rs As DAO.Recordset
strSQL = "SELECT Customer.[CustomerID], " & _
                "       Customer.[fName], " & _
                "       Vehicle.[VehicleID], " & _
                "       MonthlyPass.[SerialNumber], " & _
                "       MonthlyPass.[Startingdate], " & _
                "       MonthlyPass.[Expirydate], " & _
                "       MonthlyPass.[Price], " & _
                "       Receipt.[ReceiptNo], " & _
                "       Receipt.[PurchaseDate], " & _
                "       Receipt.[PayMethod], " & _
                "       Receipt.[ChequeNo], " & _
                "       Receipt.[BankName], " & _
                "       Receipt.[TotalPrice] " & _
                "FROM (Customer INNER JOIN Vehicle ON  Customer.[CustomerID]=Vehicle.[CustomerID]) " & _  
                "INNER JOIN (Receipt INNER JOIN MonthlyPass ON Receipt.[ReceiptNo] = MonthlyPass.[ReceiptNo])ON Vehicle.[VehicleID] = MonthlyPass.[VehicleID] " & _
                "WHERE (((MonthlyPass.[SerialNumber])=[forms]![frmMonthlyPass]![txtSerialNumber]));"

Set rs = CurrentDb.OpenRecordset(Name:=strSQL, Type:=dbOpenDynaset)

0 个答案:

没有答案