如果我插入的变量的值为 Null,则 SQL INSERT INTO 将失败。
变量 costLab 是 Variant 数据类型。非 Null 值将是 Decimal。
db.Execute ("INSERT INTO budget
(wbsid, category, capture_date, budget_date, budget_type, month_value) " & _
"VALUES ('" & wbsid & "', 'Labor', #" & importDate & "#,
#" & monthDate & "#, 'Forecast', " & costLab & ");")
如果设置 costLab 的代码返回 Null,我想插入 Null。但是如果返回一个值,我想插入那个值。显然,我可以编写一个 If 语句来检查 null,然后直接插入“Null”,但我想知道是否有没有 If 语句通过变量插入 Null 的方法。