Community discussion forum

Database in VB

Tags:
  • 8 months ago

    Hi,

    Click Project - References... - Tick Microsoft DAO X.X Object Library - OK

    Then change the code to ....

    Dim db1 As Database
    Dim rs As DAO.Recordset

    Private Sub Form_Load()
    Set db1 = OpenDatabase(App.Path & "/../../database/Barclays.mdb")
    Set rs = db.OpenRecordset("Customer02") ' Table

    'Loop through recordset.
    rs.MoveFirst
    Do While (Not rs.EOF)
       Debug.Print rs.Fields(0) & rs.Fields(1)
       rs.MoveNext
    Loop

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 7 months ago

    Hi,

    I just cut and past from your code Big Smile
    It cannot find the location of the database
    if you type
    ? App.Path & "/../../database/Barclays.mdb"
    in the immediate window you will get 2 strings together
    It will not the path you want, thus the error.

    Try the following instead

      ChDrive App.Path
      ChDir App.Path & "\..\..\database"
      Set db1 = OpenDatabase(CurDir & "\Barclays.mdb")

Post a reply

Enter your message below

Sign in or Join us (it's free).