Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DAO error (2000 sr 1)

    i have this code, but when i run code step by step heva error 424 see the images...
    In one of the images are the list of library

    Sub TITOLI1()

    Dim oDb As DAO.Database
    Dim oRs As DAO.Recordset
    Dim itmX As ListItem
    Dim i As Integer

    Set oDb = OpenDatabase(App.Path & "db3.mdb")
    Set oRs = oDb.OpenRecordset("select * from tabella1")

    ListView1.View = lvwReport
    ListView1.ColumnHeaders.Clear
    ListView1.ColumnHeaders.Add 1, "uno", "PRODOTTO"
    ListView1.ColumnHeaders.Add 2, "due", "DESCRIZ"
    ListView1.ColumnHeaders.Add 3, "tre", "DECOR"
    ListView1.ColumnHeaders.Add 4, "quattro", "TIPSER"
    ListView1.ColumnHeaders.Add 5, "cinque", "ABI"

    While Not oRs.EOF
    Set itmX = ListView1.ListItems.Add(, , oRs.Fields(0).Value)
    For i = 1 To ListView1.ColumnHeaders.COUNT - 1
    itmX.SubItems(i) = oRs.Fields(i).Value
    Next i
    oRs.MoveNext
    Wend

    Set itmX = Nothing
    Set oRs = Nothing
    Set oDb = Nothing

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DAO error (2000 sr 1)

    Why are you using DAO? You used ADO previously when you wanted to transfer data from or to an Access database. And you still have a reference to the ADO library (Microsoft ActiveX Data Objects 2.8 Library). It can be dangerous to mix DAO and ADO in the same code.

    Try changing

    Set oDb = OpenDatabase(App.Path & "db3.mdb")

    to

    Set oDb = DBEngine.OpenDatabase(App.Path & "db3.mdb")

Posting Permissions

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