Displaying the number of records in a database 
Author Message
 Displaying the number of records in a database

Quote:

> I am trying to use the following to indicate which record is being dispalyed
> from an access database: -

> lblRecordNumber.Caption = "Record: " & gCurrentRecord & "of " &
> (Data1.Recordset.RecordCount)

> Populating the variable gCurrentRecord is no problem but basically the whole
> thing doesn't work. I get an error 91 "Object variable or With block
> variable not set". I cannot work out what is wrong. I have tried using help
> to no avail.

> All I am trying to do is indicate that the record displayed is "Record X of
> Y" records.

Pete,
  You said you can populate your current record variable, gCurrentRecord
- so all you need is the RecordCount?  At some point after the
DataControl is initiated, you have to MoveLast, then get the
RecordCount. If you try to get a RecordCount before the DataControl has
been initiated or recordset has been retrieved (like in Form_Load)
you'll get the Error 91.  Maybe try in Form_Activate:

  Private intRecCount As Integer 'declare in General area of form

  With Data1.Recordset
    .MoveLast
    .MoveFirst
    intRecCount = .RecordCount
  End With

...then use the variable intRecCount when referring to the RecordCount
--
Jim in Cleveland
If you're writing to me, in my address
change "REAL_Address.see.below" to "worldnet.att.net"

"What's so funny 'bout peace, love & understanding?"
     - Nick Lowe



Tue, 19 Mar 2002 03:00:00 GMT  
 Displaying the number of records in a database
I am trying to use the following to indicate which record is being dispalyed
from an access database: -

lblRecordNumber.Caption = "Record: " & gCurrentRecord & "of " &
(Data1.Recordset.RecordCount)

Populating the variable gCurrentRecord is no problem but basically the whole
thing doesn't work. I get an error 91 "Object variable or With block
variable not set". I cannot work out what is wrong. I have tried using help
to no avail.

All I am trying to do is indicate that the record displayed is "Record X of
Y" records.

I am using vb6 with a large number of controls bound  to one data control.

Any help would be appreciated.

Pete Boys



Wed, 20 Mar 2002 03:00:00 GMT  
 Displaying the number of records in a database
That worked a treat, thanks.

Pete



Quote:

> > I am trying to use the following to indicate which record is being
dispalyed
> > from an access database: -

> > lblRecordNumber.Caption = "Record: " & gCurrentRecord & "of " &
> > (Data1.Recordset.RecordCount)

> > Populating the variable gCurrentRecord is no problem but basically the
whole
> > thing doesn't work. I get an error 91 "Object variable or With block
> > variable not set". I cannot work out what is wrong. I have tried using
help
> > to no avail.

> > All I am trying to do is indicate that the record displayed is "Record X
of
> > Y" records.

> Pete,
>   You said you can populate your current record variable, gCurrentRecord
> - so all you need is the RecordCount?  At some point after the
> DataControl is initiated, you have to MoveLast, then get the
> RecordCount. If you try to get a RecordCount before the DataControl has
> been initiated or recordset has been retrieved (like in Form_Load)
> you'll get the Error 91.  Maybe try in Form_Activate:

>   Private intRecCount As Integer 'declare in General area of form

>   With Data1.Recordset
>     .MoveLast
>     .MoveFirst
>     intRecCount = .RecordCount
>   End With

> ...then use the variable intRecCount when referring to the RecordCount
> --
> Jim in Cleveland
> If you're writing to me, in my address
> change "REAL_Address.see.below" to "worldnet.att.net"

> "What's so funny 'bout peace, love & understanding?"
>      - Nick Lowe



Thu, 21 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Record number display on Forms

2. Display record number in VB3

3. (ADO)Displaying a set number of records..

4. Displaying the number of records.

5. Trouble retrieving a fairly large number of records from a database

6. How to keep database in a fix number of records

7. Finding the total number of records in a database file

8. How Do You Count the Number of Existing Records in an Access Database

9. Number of Access Database Records

10. Refreshing database record display forms

11. Displaying all records from a database

12. typical code for displaying and editing records from database table(s) in a grid in unbound mode

 

 
Powered by phpBB® Forum Software