2

我正在尝试创建以下 SQL INSERT INTO 语句,但出现语法错误。有什么建议么?:

SQL = "
INSERT INTO AptRent 
    (BuildingID,
     RentAmountID, 
     InitialRentDueDate, 
     TenantID, 
     AptNoID, 
     MoveInDate, 
     MoveOutDate,  
     DateAdded, 
     SecurityAmount, 
     SecurityPaid, 
     NoDaysLate, 
     LateAmount) 
    VALUES
    (" & Me.cbSelectBuildingForRental & "," 
       & Me.cbCreateRentalRentAmount & "," 
       & Me.tbCreateRentalRDD & "," 
       & Me.cbSelectTenantForRental & ", '" 
       & Me.cbSelectAptNoforRental & "' ," 
       & Me.tbCreateRentalMID & "," 
       & Me.tbCreateRentalMOD & "," 
       & Now() & "," 
       & Me.tbSecurityAmnt & "," 
       & Me.ckSecurityPd & "," 
       & Me.tbNoDaysLate & "," 
       & Me.tbLatePmnt & ")"

AptRent具有以下数据类型:

BuildingRentID:自动编号

BuildingID:编号(Me.cbSelectBuildingForRental

RentAmountID : 数字 ( Me.cbCreateRentalRentAmount )

InitialRentDueDate:日期/时间(Me.tbCreateRentalRDD

租户ID:编号 ( Me.cbSelectTenantForRental )

AptNoID:文本(Me.cbSelectAptNoforRental

MoveInDate:日期/时间(Me.tbCreateRentalMID

MoveOutDate:日期/时间(Me.tbCreateRentalMOD

添加日期:日期/时间(现在()

SecurityAmount : 货币 ( Me.tbSecurityAmnt )

SecurityPaid:是/否(Me.ckSecurityPd

NoDaysLate : 数字 ( Me.tbNoDaysLate )

LateAmount:货币(Me.tbLatePmnt

4

1 回答 1

1

假设它们是 ISO 格式 (YYYY-MM-DD HH:NN:SS),您需要在日期/时间值周围添加单引号。

...
& "'" & Me.tbCreateRentalMID & "', " 
...

依此类推,适用于所有日期/时间列。

于 2012-10-19T21:38:45.727 回答