Results 1 to 5 of 5

Thread: Pulling a desired number of records from a source

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    alb, nm 87112
    Posts
    56

    Post

    I need to pull the first 100 records from a database table in Access using VB. I know this is simple, but for some reason it is giving me fits.

    Any suggestions?

    Thanks!

  2. #2
    New Member
    Join Date
    Jan 2000
    Location
    Singapore
    Posts
    10

    Post

    You might want to try opening the table using dbOpenTable instead of dbOpenSnapShot. Sometimes SnapShot gives me a recordcount of 1, when there are over 10,000 records.

    Set db1 = dBEngine.Workspaces(0).OpenDatabase("W:\DB\info.mdb")
    Set table_proj = db1.OpenRecordset("proj", dbOpenTable)

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    alb, nm 87112
    Posts
    56

    Post

    Thanks for the help, but I don't think I was clear enough (my fault).

    I don't need a count, I need to pull the first 100 records from the database table, and export them to a text file.

    Can you help?

    Thanks!

  4. #4
    Lively Member
    Join Date
    Feb 1999
    Location
    Caracas, Miranda, Venezuela
    Posts
    69

    Post Obtaining the first 100 records

    You can use for example

    Data1.Recordsource = " SELECT TOP 100 WHERE FirstName = " + "'" + "Rafael" + "'" + " ORDER BY Age "


  5. #5
    New Member
    Join Date
    Jan 2000
    Location
    Singapore
    Posts
    10

    Post

    Set db1 = dBEngine.Workspaces(0).OpenDatabase("W:\DB\info.mdb")
    Set table_proj = db1.OpenRecordset("proj", dbOpenTable)

    if table_proj.recordcount > 0 then
    table_proj.movefirst

    for i = 1 to 100
    'do your fetching of information here
    txtname.txt = table_proj("Name")
    next
    endif

    -=-=-=
    Hope the above works :P

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