简体   繁体   中英

Ms Access VBA - Trying to call data from a combo box but only if a field is empty

From the code below I want [KronosNO] to come from a database Combo box but only if the [RTWDate] column is Null.

Set Rs = Application.CurrentDb.OpenRecordset(
  "SELECT * FROM tblAbsence WHERE [KronosNo] = '" & Me.cmbKronosNo.Value & "' 
   AND [RTWDate] = '" & "Is Null" & "' ", dbOpenDynaset)

Don't treat Is Null like a variable, it is a part of SQL.

You simply need

AND [RTWDate] Is Null

in your string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM