I have a form, and am counting the number of records in a subform. Sometimes the subform is empty, which I'd like to check for, but it throws
Run-time error '2427': You entered an expression that has no value
It's obvious why this error is happening, but less obvious is how to work around it. This is the code causing the error. MainTableComboBox.Value contains RecordID.
DCount("*", "[SubFormTable]", "[SubFormTable].[RecordID] = " & MainTableTextBox.Value)
I've tried the following but it still errors out.
- Using
If(IsError(Dcount...)) then (do stuff)
- Checking that the number of records is larger than zero
- Nested Nothing, IfNull, and IfEmpty statements
- Using an error handler
What other ways exist to get around this error?
Customers
and the subform usesProducts
. A customer may or may not have any products listed. – jjjjjjjjjjjOption Explicit
and Christopher's answer below, and it worked. Thank you all. – jjjjjjjjjjj