I know I'm over thinking this, but I want to check a single value/field within a single record. For instance, I want to know if the value of the "closedDate" field in the record with the primary key of 33 is null or not.
I was thinking something like:
dim db as DAO.Database
dim rs as DAO.Recordset
set db = CurrentDb
set rs = db.OpenRecordset("record_holdData")
If not isNull(rs.Fields("closedDate")) then
'do nothing
Else
'add a close date
End If
But I don't think this is right. It doesn't specify the record number. In the application, the form is opened by being bound to the record in question, but I don't think CurrentDb
takes that into consideration and rather references the entire table.
So my question is, how do open the recordset in this fashion and reference this field in that particular record only?
You found the answer you wanted, but I would use the DLookup Function instead.
Dim db As DAO.Database
Dim strWhere As String
Dim varClosedDate As Variant
Set db = CurrentDb
strWhere = "id = 33"
varClosedDate = DLookup("closedDate","record_holdData",strWhere)
If IsNull(varClosedDate) = True Then
'use today's date as closedDate
db.Execute "UPDATE record_holdData Set closedDate = Date() WHERE " & strWhere
End If