cnn.Open cns, cnp1, cnp2
cmd.ActiveConnection = cnn
cmd.CommandText = SqlCmd
Set rst = cmd.Execute
rst.Close
rst.CursorType = adOpenKeyset
rst.Open
Try Closing the recordset , set cursortype to adOpenkeyset and reopen . Then
Recordcount will return total number of records. It works.
Anita
> -----Original Message-----
> From: philip.moh@a... [SMTP:philip.moh@a...]
> Sent: Monday 31 December 2001 13:23
> To: professional vb
> Subject: [pro_vb] record count
>
> Hi,
>
> Does anyone know how to get the total record?
>
> I do the following but got -1 as total record:
> ----------
> myConn.Open "DSN=poinfo"
> mySql1 = "Select * from newPO"
>
> myRec1.Open mySql1, myConn, adOpenDynamic, adLockOptimistic
> myRec1.MoveLast
> cNum = myRec1.RecordCount
>
> MsgBox cNum
> myRec1.MoveFirst
> cKey = myRec1!Field1
> ----------
>
> when I do the message box, I got -1 as the total record...why???
>
> Thanks in advance.
>
>
>
>
>