Number of records = -1

  • Thread starter Thread starter dhstein
  • Start date Start date
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.
 
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
 
You are using a disconnected recordset? a forward only recordset?

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

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