Hi, first of all sorry if I post this in the wrong section. Cant find where is the VBScript Section.

I'm new to VBScripting. What I need is the VBScript to count the number of record in my MSAccess table. I tried total = "SELECT COUNT(*) FROM Product" But it doesn't seems like working. There's a mismatch type error. I created another object and connect it to my MSAcess table and do a DO WHILE loop to count the number of record. Any other better suggestions??

Thanks...

Try something like this. If first creates and sets a connection and recordset, opens the recordset (SELET * FROM [Product]) and then loops through the recordset, counter the number of records as it goes through the loop.

Dim cnn As ADODB.Connection
  Dim rst As ADODB.Recordset
  Dim queryString As String
  
  Set cnn = CurrentProject.Connection
  Set rst = New ADODB.Recordset

  queryString = "SELECT * FROM [Product]"
  rst.Open queryString, cnn

  dim counter as long
  counter = 0
  while not rst.eof
    counter = counter+1
    rst.movenext
  wend

Thanks. This is what I have in mind. :) Thanks...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.