Recordset.clone record count issue

J

JHB

I have a form which is intended to display a list of records when more
than one results from a selection. It is executing the following code
on Open. The code is intended to call a macro when ONLY one record is
in the selected table. When more than one record (and less than 100)
are found it is supposed to drop through the macro and show the form
it is associated with. The form gets its data from a Temporary table
of records. The issue I have it that the code appears to work when
more than 100 records are in the table and when there are NO records
BUT IT ALWAYS EXECUTED THE MACRO WHEN THERE ARE NOT 100 OR 0 RECORDS.
In other words when the record count is 2 it does NOT drop through the
code.

Could someone either (a) show me how to display the record count that
his code is working (which may be the problem)with OR tell me what on
earth could be happening!

Thanks in advance

John Baker

Private Sub Form_Open(Cancel As Integer)

If Me.RecordsetClone.RecordCount > 100 Then
MsgBox "You have more that 100 items selected. Try again", vbOKOnly
Cancel = True

End If

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No Locations found with these keys", vbOKOnly
Cancel = True
End If


If Me.RecordsetClone.RecordCount = 1 Then
DoCmd.RunMacro "Locations2update"

End If
 
A

Access Developer

Try doing a .MoveLast on the Recordset, and then checking .RecordCount.
RecordCount is a count of the number of records accessed, or passed, in the
Recordset, not just a count of records that exist in the Recordset -- that's
documented, but is, admittedly, an "unintuitive" definition given the name
of the property. Most of us have had to learn this 'the hard way'.
 
J

JHB

Thank you for your response.

Hummm.. I tried that, and it did not appear to make any difference to
the results. The situation now is that when there is MORE than one
record, things appear to work fine. HOWEVER when there is just one
record nothing programmed seems to recognize that the record exists. I
can see the record in the table, and it appears on forms, but as far
as any detection by programs it just is not happening. I have tried
reconstructing the table from. scratch and the same thing continues to
happen. The strange thing is I have a number of other tables where I
am doing exactly the same thing and it works fine.. I have been over
the ones that work with a fine tooth comb and see no coding
differences (except for names and fields). Any further suggestions
would be welcomed.

Best

John Baker
 
J

JHB

Try doing a .MoveLast on the Recordset, and then checking .RecordCount.
RecordCount is a count of the number of records accessed, or passed, in the
Recordset, not just a count of records that exist in the Recordset -- that's
documented, but is, admittedly, an "unintuitive" definition given the name
of the property. Most of us have had to learn this 'the hard way'.

Following up I owe you an apology. I found the basic issue and it
was , as you might expect, a stupid mistake on my part! The process
now works.

Thank you for responding and I am sorry I wasted your time. I did ,
however, learn something about the record count that I had not
previously known.That could be very useful in the future.
 

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