how to extract data from first access table and use it another vba application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prasad joshi
    New Member
    • Aug 2012
    • 30

    how to extract data from first access table and use it another vba application

    i want to extract data from 1st access table and use that data in another access vba application .


    how to do data extraction????
    please sujjest me some sample vba code for data extraction
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Is this a VB or VBA question? They are not the same and you are probably posting in the wrong forum.

    Comment

    • kadghar
      Recognized Expert Top Contributor
      • Apr 2007
      • 1302

      #3
      Of course its VBA, Rabbit.

      Anyway, if your Access DB is an MDB, then you can do this:
      1) Make sure you add this reference to your VBA project:
      Microsoft DAO Object Library.

      2) Use a DataBase object and a Recordset; something like:
      Code:
      Dim DBobj As Database
      Dim RSet As Recordset
      Set DBobj = DBEngine.Workspaces(0).OpenDatabase([I]yourfile.mdb[/I])
      Set RSet = DBobj.OpenRecordset("SELECT * FROM table WHERE...")
      While not RSet.EOF
          MsgBox RSet("anyField")
          'do something else
          RSet.MoveNext
      Wend

      Comment

      • prasad joshi
        New Member
        • Aug 2012
        • 30

        #4
        hello i am using access 2007 accdb database.

        what will be same code for access 2007 accdb.

        Comment

        • kadghar
          Recognized Expert Top Contributor
          • Apr 2007
          • 1302

          #5
          Mmm, I'm not sure; but you can always save as MDB

          Comment

          • zmbd
            Recognized Expert Moderator Expert
            • Mar 2012
            • 5501

            #6
            Yes the code will be basiclly the same...
            make sure to use the correct file name.
            -z

            Comment

            Working...