Verify for value in field

D

Daniel P

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
 
C

Chris

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?
 
R

Rodrigo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top