Heenan, Lambert
Lambert.Heenan at AIG.com
Wed May 25 12:41:08 CDT 2005
Try this... Function bIsTableEmpty(strDataSource As String) As Boolean Dim db As DAO.Database Dim rs As DAO.Recordset Set db = DBEngine(0)(0) Set rs = db.OpenRecordset(strDataSource, dbOpenForwardOnly) With rs On Error Resume Next .MoveFirst If Err.Number <> 0 Then bIsTableEmpty = True On Error GoTo 0 bIsTableEmpty = .EOF .Close End With Set rs = Nothing Set db = Nothing End Function If the table / query has no records then the .MoveFirst line will cause an error. This is trapped to give you the result you want. HTH Lambert -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Hale, Jim Sent: Wednesday, May 25, 2005 1:19 PM To: 'Accessd (E-mail) Subject: [AccessD] Record count What is the easiest way in code to determine if a table has at least one record? TIA Jim Hale *********************************************************************** The information transmitted is intended solely for the individual or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of or taking action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this email in error please contact the sender and delete the material from any computer. As a recipient of this email, you are responsible for screening its contents and the contents of any attachments for the presence of viruses. No liability is accepted for any damages caused by any virus transmitted by this email.