Re: Retrieving data from user input.
- From: Marshall Barton <marshbarton@xxxxxxxxxx>
- Date: Thu, 04 Oct 2007 01:03:04 -0500
J_Goddard via AccessMonster.com wrote:
I don't know what version of Access you have, but in A2000 your code won't
work because of the if rs.recordcount > 0 line. The recordcount for a
recordset is not accurate until all the records in the recordset have been
accessed. Since in your IF statement you have not accessed any records yet,
the Recordcount property is still 0.
To check if the retrieval returned any records, you can use
if not rs.BOF then....
I suspect this might have been the problem when you stated that the code
compiled and ran without errors, but no fields were filled in.
Saying the RecordCount is not accurate is not the same as
saying it is totally inaccurate. While it may not give the
total number of records in the recordset, it is guaranteed
to return a value greater than 0 if the recordset returns at
least one record. The key to thinking about this issue is
that "the number of records accessed so far" refers to
Access accessing the records, which is not necessarily the
same as the number of records the VBA code has accessed.
Checking RecordCount>0 on a newly opened recordset is just
as valid as checking BOF And EOF. This is true because if
the recordset returns any records, then Access has retrieved
at least one record. I.e. If neither BOF nor EOF is True,
then there must be a current record (which is guaranteed to
be the first record in a newly opened recordset).
--
Marsh
MVP [MS Access]
.
- Follow-Ups:
- Re: Retrieving data from user input.
- From: J_Goddard via AccessMonster.com
- Re: Retrieving data from user input.
- References:
- RE: Retrieving data from user input.
- From: J_Goddard via AccessMonster.com
- RE: Retrieving data from user input.
- Prev by Date: RE: Pass value to form
- Next by Date: Re: Retrieving data from user input.
- Previous by thread: RE: Retrieving data from user input.
- Next by thread: Re: Retrieving data from user input.
- Index(es):
Relevant Pages
|