I'm a bit confused on how exactly VBA views empty field values in a table/datasheet because I'm trying to use Recordset.FindFirst method to locate a record within my datasheet, but if the record contains a field that is empty, it cannot locate the record.
For example, here's what my table may look like:
FieldOne FieldTwo
123 SomeName1
456
789 SomeName2
For record 456, the value in FieldTwo is empty. The datatype for FieldOne and FieldTwo is a Short Text.
Assume myDatasheet is linked to the above table with those mentioned records.
I attempt to find the record 123 like so:
Dim crit As String
crit = "FieldOne = '" & Me.textBoxOne & "' And " & _
"FielTwo = '" & Me.textBoxTwo & "'"
With myDatasheet.Form
.RecordsetClone.FindFirst crit
If Not .RecordsetClone.NoMatch Then
MsgBox "FOUND"
Else
MsgBox "NOT FOUND"
End If
End With
Where the value in Me.textBoxOne is 123 and in Me.textBoxTwo is SomeName1 and I get a FOUND.
However, if I try to find record 456 using Me.textBoxOne as 456 and Me.textBoxTwo as "", I get a NOT FOUND.
There's got to be something syntactically wrong with my code. What should the correct criteria be?
Thanks.