Number of records = -1

D

dhstein

I have the code below:

NumRecords = CurrentDb.TableDefs(TblName).RecordCount

MsgBox TblName & " has " & NumRecords & " records"


I get a display that the record count is -1

Any ideas why this is wrong ? Thanks.
 
S

Stefan Hoffmann

hi,
NumRecords = CurrentDb.TableDefs(TblName).RecordCount
MsgBox TblName & " has " & NumRecords & " records"
Nice idea.
I get a display that the record count is -1
For linked tables it is always -1.


mfG
--> stefan <--
 
C

Clifford Bass

Hi,

You may wish to use the DCount() function:

NumRecords = DCount("*", "TblName")

It should work regardless of whether the table is linked or local.

Clifford Bass
 
M

Michel Walsh

You are using a disconnected recordset? a forward only recordset?

Vanderghast, Access MVP
 
5

555

¹ØÓÚ´óѧÉúѧϰ״̬µÄµ÷²é

Ä¿Ç°£¬ÎªÁ˽øÒ»²½Á˽â¸÷λͬѧµÄѧϰ¡¢Éú»îºÍ¶ÌÆÚÄ¿±ê£¬ÌØÒâ×éÖ¯Á˴˴ε÷²é»î
¶¯¡£Èôó¼ÒÈ«Ãæ¿Í¹ÛµØ×ö³öÑ¡Ôñ£¬ÕæʵµØ·´Ó³ÎÒÃÇ°àͬѧµÄѧϰÏÖ×´ºÍ´æÔÚµÄÎÊÌ⣬Ϊ
ÎÒÃÇ°àÒÔºóµÄŬÁ¦·½ÏòºÍÖƶ¨¹ÜÀí°à¼¶´ëÊ©£¬ÌṩÁËÓÐÀûµÄ²Î¿¼£¬ÒÔ¼°ÄÜÈÃͬѧÃǸü¼Ó
Ã÷È·×Ô¼º·¢Õ¹·½ÏòºÍÈËÉúÄ¿±ê£¬´Ù½øͬѧÃǸÄÉƲ»ºÃµÄѧϰºÍÉú»î·½Ê½¡£.......
 

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