S
Stephen @ ZennHAUS
Hi Guys and Gals
I wrote a whole lot of code the other day to do this in a test copy of my DB
and deleted the test DB without realizing I hadn't copied the code yet. YAY
for me.
Anyway, I have a form for editing records for a particular table. When the
form loads, it is supposed to run some code that changes the layout of the
form depending on the content of the record to be displayed (it also does
this for Form_Dirty and Form_Current so that as the data changes the form
can "redesign" itself).
Problem is, the table is currently empty and if a user opens the form the
code halts with an error because there are no records in the table. So, I
want a way to count the records in the table BEFORE I execute the code that
redesigns the form so that if there are no records I can display a message
to tell the user to add records before trying to edit them.
The way I did it before was cumbersome. I ran a query (in code, so
connections and recordsets etc.) on the table to count the records in the ID
field. then if the result of the first field in the first row of the records
set =0, I displayed the message then closed the form, otherwise I ran the
code to redesign the form layout.
Any ideas on a quicker and easier method of counting records in recordset of
a form from Form_Load. I have about 20 forms I need to do this to once I get
it working again.
Cheers
Stephen @ ZennHAUS
I wrote a whole lot of code the other day to do this in a test copy of my DB
and deleted the test DB without realizing I hadn't copied the code yet. YAY
for me.
Anyway, I have a form for editing records for a particular table. When the
form loads, it is supposed to run some code that changes the layout of the
form depending on the content of the record to be displayed (it also does
this for Form_Dirty and Form_Current so that as the data changes the form
can "redesign" itself).
Problem is, the table is currently empty and if a user opens the form the
code halts with an error because there are no records in the table. So, I
want a way to count the records in the table BEFORE I execute the code that
redesigns the form so that if there are no records I can display a message
to tell the user to add records before trying to edit them.
The way I did it before was cumbersome. I ran a query (in code, so
connections and recordsets etc.) on the table to count the records in the ID
field. then if the result of the first field in the first row of the records
set =0, I displayed the message then closed the form, otherwise I ran the
code to redesign the form layout.
Any ideas on a quicker and easier method of counting records in recordset of
a form from Form_Load. I have about 20 forms I need to do this to once I get
it working again.
Cheers
Stephen @ ZennHAUS