CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: VBA Recordcount

Threaded View

  1. #1
    Join Date
    Nov 2002
    Location
    Netherlands
    Posts
    132

    VBA Recordcount

    Hi Guru's,

    I did a search on this subject but no one has encountered the error I am having. This is the code

    ------------------------------------------------------------------
    Dim conn As ADODB.Connection
    Dim rst As ADODB.Recordset

    Set conn = New ADODB.Connection
    Set rst = New ADODB.Recordset

    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & "G:\NAWKLANT\FONTYS\FONTYS.MDB" & ";Persist Security Info=False"
    conn.Open

    rst.CursorLocation = adUseClient
    rst.CursorType = adOpenStatic
    rst.LockType = adLockBatchOptimistic
    rst.Open "SELECT * FROM Studenten"

    Number = rst.RecordCount

    rst.MoveLast
    rst.MoveFirst

    txtRecCount.Text = Number
    --------------------------------------------------------------------

    I get an error at the rst.open part saying that this connection can not be used for this action, or this action is not valid in this context.

    Hope someone can tell me what I am doing wrong and excuse my newbieness.

    Thanks in advance,

    Jasper
    Last edited by Jasper XAFAX; March 4th, 2004 at 04:39 AM.
    Flying is to throw yourself on the ground and miss

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured