DAO No Record error trapping

DAO No Record error trapping

Post by enduse » Wed, 24 Feb 1999 04:00:00



I have created a database program that utilizes classes to access tables
within the database.  For instance, I have created a customer class with
all the properties that access the customer table in my database.  (BTW,
it is an Access database).  However, when the class is initialized upon
the user activating the front-end to the table, and if there are no
records in the table, the class returns the DAO no record error.  I know
this is trappable and have done so, but the methods I have used are a
bit clumsy.  I am looking for a more efficient way to allow the user to
enter a new record upon being advised that the recordset contains no
records.  To date I have employed a separate form to do this upon a no
record flag being thrown.  But this just duplicates the data entry form
that the user would normally use on the recordset if there are records.
The other method I have employed is to automatically create a dummy
record, so that the user gets to the data entry screen without having to
deal with an error or having to do any actual work.  However, the dummy
record is just a bunch of ****** entered in the appropriate textboxes.
The recordcount is adjusted to reflect this entry, that is, it is
subtracted out.  But, now I get a dataentry form, regardless of the
number of records in the recordset, which comes up showing this dummy
record.

Does any one have some idea as to how to efficiently trap the no record
error and allow the user a choice as to how to act at the time?

Thank you.