检查附件字段是否为空vba访问

时间:2013-07-08 22:03:03

标签: vba combobox access-vba attachment-field

我有一个带有组合框的表单,供用户从一系列日期中进行选择。表单基于一个表,其中每个日期都是记录。每个日期最多有6个附件,每个附件都在一个单独的字段中。当用户选择日期时,如何检查附件字段是否为空?我正在尝试编写“On Click”事件。

我还希望这样做,以便如果某个字段缺少附件,那么通常允许用户选择该附件的复选框将显示为灰色并说出“此日期不存在数据”< / p>

我尝试做一个简单的if语句

'Go through the recordset, testing each record to see if the date matches the selected one
'If it doesn't match, go to the next one
While Not fldDate = dteDate
    rst.MoveNext
    Wend
MsgBox fldDate

If rstPIANO.Fields("FileName") = Null Then MsgBox "No PIANO Data exists for this date"
If rstMassBalance.Value = Null Then MsgBox "No Mass Balance Data exists for this date"
If rstIR.Value = Null Then MsgBox "No IR Data exists for this date"
If rstD86.Value = Null Then MsgBox "No D86 Data exists for this date"
If rstGC.Value = Null Then MsgBox "No GC Data exists for this date"
If rstMiniGasGraphs.Value = Null Then MsgBox "No Mini Gas Graph Data exists for this date"

这给了我一个错误,上面写着“对象无效或不再设置”

1 个答案:

答案 0 :(得分:0)

您的记录集首先被调用 你在每个IF语句中称它为不同的东西 rstPiano不存在 使用 如果rst.fields(“Piano”)= null