Nimber of Records

J

JamesJ

The following code in the OnCurrent of my form doesn' display 0 Items as I
wish
when the form returns no records.

If IsNull(Me!ProductID) Then

Me.txtCount = Me.RecordsetClone.RecordCount & "0 Item(s)"

Else
Me.RecordsetClone.MoveLast
Me.txtCount = Me.RecordsetClone.RecordCount & " Item(s)"
End If

Any ideas,
James
 
S

Sam

Try:

Me.RecordsetClone.MoveLast
Me.txtCount = Me.RecordsetClone.RecordCount & " Item(s)"

Sam
 
J

JamesJ

I put that into the part after If IsNull...
I'm even unable to generate a message box if it returns no records.
This is a split form in access 2007.
 
M

Mr B

Hi again, JamesJ.

Just a thought and question: Is it possible that you have a blank record in
your table?

The only reason that I ask is that, again, your code works as expected here
for me.

The only reason that I can think of that would cause your code to not
execute the code that is expected to run when the ProductId is null is that
the table is not empty of records. Just for grins why don't you create a new
table with an autonumber field and one other text field. Then just have
Access to create the spilit form and test your code in the new form to see if
you get it to work.
 
M

Mr B

Hi again, JamesJ.

Just a thought and question: Is it possible that you have a blank record in
your table?

The only reason that I ask is that, again, your code works as expected here
for me.

The only reason that I can think of that would cause your code to not
execute the code that is expected to run when the ProductId is null is that
the table is not empty of records. Just for grins why don't you create a new
table with an autonumber field and one other text field. Then just have
Access to create the spilit form and test your code in the new form to see if
you get it to work.
 
S

Sam

James, how about:

If IsNull(Me.ProductID) Then
Me.txtCount="0 Item(s)"
Else
same code you have now
End IF
 
J

JamesJ

ProductID is an Autonumber field.
Even if I had a blank record it should show 1 item.
I even set the Autonumber field to Visible and it showed
no value.
I'm filtering the records using a combo box populated by a lookup table.
One of the the selections I know has no records.

James
 
J

JamesJ

I think That' swhat I tried first so I figured I through the RecordsetClone
in.
I'm filtering the records using a combo box populated by a lookup table.
One of the the selections in the cbo I know has no records.

James
 

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

Similar Threads


Top