Number of Records in a Table

  • Thread starter Cipher via AccessMonster.com
  • Start date
C

Cipher via AccessMonster.com

I am using:
Dim Max_Record As Integer
Set rs = New ADODB.Recordset
StrOne = "SELECT * FROM Inject_Cycle " & "WHERE ID=" & Record_Number
rs.Open StrOne, CurrentProject.Connection, adOpenForwardOnly,
adLockReadOnly
Max_Record = Count()

There are only 8 records in the Table Inject_Cycle, so why does Count()
return 39? If I change to:
Max_Record = Count(*), I get a "Compiler Error: Syntax error"
 
B

Brian

Not sure why the count is off, but you might try this instead. It is simpler.

Dim Max_Record As Integer
Max_Record = DCount("*","[Inject_Cycle]","ID = " & Record_Number)
 
D

Dirk Goldgar

Cipher via AccessMonster.com said:
I am using:
Dim Max_Record As Integer
Set rs = New ADODB.Recordset
StrOne = "SELECT * FROM Inject_Cycle " & "WHERE ID=" &
Record_Number
rs.Open StrOne, CurrentProject.Connection, adOpenForwardOnly,
adLockReadOnly
Max_Record = Count()

There are only 8 records in the Table Inject_Cycle, so why does Count()
return 39? If I change to:
Max_Record = Count(*), I get a "Compiler Error: Syntax error"


That code doesn't make any sense to me. Your reference to the Count()
function has nothing to do with the recordset. I don't understand why you
would get *any* value back from it in this context, unless you have defined
your own function called "Count".

If you want to know how many records are in the recordset, you would
normally interrogate the recordset's RecordCount property. However, as
you've opened a forward-only recordset, that count will always be -1. If
you want to be able to use the RecordCount property, use adOpenStatic or
adOpenKeyset.
 
C

Cipher via AccessMonster.com

Thank you Brian, you help is much appreciated
Not sure why the count is off, but you might try this instead. It is simpler.

Dim Max_Record As Integer
Max_Record = DCount("*","[Inject_Cycle]","ID = " & Record_Number)
I am using:
Dim Max_Record As Integer
[quoted text clipped - 7 lines]
return 39? If I change to:
Max_Record = Count(*), I get a "Compiler Error: Syntax error"
 
C

Cipher via AccessMonster.com

Dirk:

If you look through all of the postings you will see that you have done
nothing except criticize. The whole idea of this site is to ASSIST people. If
we knew what we were doing, there would be no need to post anything. Please
do me a favor and ignore anything from me in the future, I no longer want you
to communicate with you. If you do not refrain from this aggressive attitude
people will no longer come to this site.

Dirk said:
I am using:
Dim Max_Record As Integer
[quoted text clipped - 8 lines]
return 39? If I change to:
Max_Record = Count(*), I get a "Compiler Error: Syntax error"

That code doesn't make any sense to me. Your reference to the Count()
function has nothing to do with the recordset. I don't understand why you
would get *any* value back from it in this context, unless you have defined
your own function called "Count".

If you want to know how many records are in the recordset, you would
normally interrogate the recordset's RecordCount property. However, as
you've opened a forward-only recordset, that count will always be -1. If
you want to be able to use the RecordCount property, use adOpenStatic or
adOpenKeyset.
 
D

Douglas J. Steele

Sorry, but I think you're out of line here.

Dirk's responses are usually well thought out and complete. I did a quick
review of all of the threads you have in this newsgroup, and nothing he said
strikes me as being unreasonable.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Cipher via AccessMonster.com said:
Dirk:

If you look through all of the postings you will see that you have done
nothing except criticize. The whole idea of this site is to ASSIST people.
If
we knew what we were doing, there would be no need to post anything.
Please
do me a favor and ignore anything from me in the future, I no longer want
you
to communicate with you. If you do not refrain from this aggressive
attitude
people will no longer come to this site.

Dirk said:
I am using:
Dim Max_Record As Integer
[quoted text clipped - 8 lines]
return 39? If I change to:
Max_Record = Count(*), I get a "Compiler Error: Syntax error"

That code doesn't make any sense to me. Your reference to the Count()
function has nothing to do with the recordset. I don't understand why you
would get *any* value back from it in this context, unless you have
defined
your own function called "Count".

If you want to know how many records are in the recordset, you would
normally interrogate the recordset's RecordCount property. However, as
you've opened a forward-only recordset, that count will always be -1. If
you want to be able to use the RecordCount property, use adOpenStatic or
adOpenKeyset.
 
D

Dirk Goldgar

Cipher via AccessMonster.com said:
Dirk:

If you look through all of the postings you will see that you have done
nothing except criticize. The whole idea of this site is to ASSIST people.
If
we knew what we were doing, there would be no need to post anything.
Please
do me a favor and ignore anything from me in the future, I no longer want
you
to communicate with you. If you do not refrain from this aggressive
attitude
people will no longer come to this site.


I regret that I am unable to assist you, despite having spent hours
attempting to do so. On a personal level, I regret that you have
misunderstood the tone and intention of my answers. Best of luck in your
future endeavors..
 

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