Verify for value in field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I verify if a column in a table contains at least 1 true value and if not generate a msg

Thank yo

Daniel
 
If DCOUNT("Column","Table","Column=True") = 0 then
MSGBOX "Error"
End IF



Chris
-----Original Message-----
How can I verify if a column in a table contains at least
1 true value and if not generate a msg?
 
Call my HasRecords function this way

strsql holding the table or query you want to test, and istruefalsefieldname
being the name of the field you want to test for a true value


Rodrigo.



sub Test()
dim strSql as str
strSql = " SELECT tmpTable.* FROM tmpTableWHERE ( IsTrueFalseFieldName =
True ) ; "

if not hasrecords(strsql) then
msgbox "No True value found"
end if

end sub

Public Function HasRecords(Tbl_or_SQL_Source As String) As Boolean
On Error Resume Next
dim db as dao.database
dim rs as dao.recordset
Set db = DBEngine(0)(0)
Set rs = db.OpenRecordset(Tbl_or_SQL_Source, dbOpenDynaset, dbReadOnly)
HasRecords = Not (rs.EOF And rs.BOF)
Set rs = Nothing
Set db = Nothing
End Function
 
Back
Top