From: Maracay on
Hi Guys

I need to know how many records I have in my record source that why I am
using rs.RecordCount after my sql statement, if there are no records I got
zero that is OK, but if I got more than 1 record I got a 1, what I want to
know is the exact number of records in my record source.

Thanks

From: Jon Lewis on
You need to move to the end of the recordset to 'populate' the RecordCount
property. Try:

rs.MoveLast
rs.MoveFirst
rs.RecordCount 'should then return the correct count

Jon

"Maracay" <Maracay(a)discussions.microsoft.com> wrote in message
news:684787E3-78B4-4531-B6EE-15EF18F3DAAB(a)microsoft.com...
> Hi Guys
>
> I need to know how many records I have in my record source that why I am
> using rs.RecordCount after my sql statement, if there are no records I got
> zero that is OK, but if I got more than 1 record I got a 1, what I want to
> know is the exact number of records in my record source.
>
> Thanks
>


From: Daniel Pineault on
You have to force the recordset to go to the last record before getting your
recordcount to ensure a proper count. You'd have to do something like:

If rs.RecordCount = 0 then
MsgBox "You have no Records."
Else
rs.MoveLast
MsgBox "You have " & rs.RecordCount & " Records."
End if


--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Maracay" wrote:

> Hi Guys
>
> I need to know how many records I have in my record source that why I am
> using rs.RecordCount after my sql statement, if there are no records I got
> zero that is OK, but if I got more than 1 record I got a 1, what I want to
> know is the exact number of records in my record source.
>
> Thanks
>
From: Maracay on
Hi Guys,

for dome reason nothings works, this is my record source

Dim NumRec As Integer
Dim rs As Recordset
Dim db As Database
Set db = CurrentDb

Set rs = db.OpenRecordset( _
"select DocketNumber " & _
"from tblDDocket " & _
"where DocketNumber = " & Me.TextDockNumb & " and
DocketSequence = " & Me.TextSequenceNumber)

after this I placed both options but nothing works.

Thanks

"Maracay" wrote:

> Hi Guys
>
> I need to know how many records I have in my record source that why I am
> using rs.RecordCount after my sql statement, if there are no records I got
> zero that is OK, but if I got more than 1 record I got a 1, what I want to
> know is the exact number of records in my record source.
>
> Thanks
>
From: Daniel Pineault on
Assuming your SQL Statement is good, then you'd do

Dim NumRec As Integer
Dim rs As Recordset
Dim db As Database
Set db = CurrentDb

Set rs = db.OpenRecordset( _
"select DocketNumber " & _
"from tblDDocket " & _
"where DocketNumber = " & Me.TextDockNumb & " and
DocketSequence = " & Me.TextSequenceNumber)

If rs.RecordCount = 0 Then
MsgBox "There are no records!"
Else
rs.MoveLast
MsgBox "There are " & Me.RecordCount & " records!"
End If

rs.Close
Set rs = Nothing
Set db = Nothing



Have you tested that you SQL statement works?!
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Maracay" wrote:

> Hi Guys,
>
> for dome reason nothings works, this is my record source
>
> Dim NumRec As Integer
> Dim rs As Recordset
> Dim db As Database
> Set db = CurrentDb
>
> Set rs = db.OpenRecordset( _
> "select DocketNumber " & _
> "from tblDDocket " & _
> "where DocketNumber = " & Me.TextDockNumb & " and
> DocketSequence = " & Me.TextSequenceNumber)
>
> after this I placed both options but nothing works.
>
> Thanks
>
> "Maracay" wrote:
>
> > Hi Guys
> >
> > I need to know how many records I have in my record source that why I am
> > using rs.RecordCount after my sql statement, if there are no records I got
> > zero that is OK, but if I got more than 1 record I got a 1, what I want to
> > know is the exact number of records in my record source.
> >
> > Thanks
> >