I want to get a count of how many rows are returned from this query in VBA
Code:
SELECT Count(ID) AS CountOfID FROM vbaImportList WHERE (((location) Is Null));
I tried to use the DCount() function, but even when the count is >= 1 my variable continue never sets as False
Code:
continue = True
missingLocation = DCount("ID", "vbaImportList", Null)
If missingLocation >= 1 Then
continue = False
End If
Debug.Print continue
Am I not understanding how DCount() works?
<strong>edit</strong>...
Should I do something like this instead
Code:
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT Count(ID) AS CountOfID FROM vbaImportList WHERE (((location) Is Null));"
Set rst = CurrentDb.OpenRecordset(strSQL)
missingLocation = rst.Fields(0)
rst.Close
Set rst = Nothing