+ Reply to Thread
Results 1 to 2 of 2

excel to access

  1. #1
    Forum Contributor
    Join Date
    05-14-2006
    Posts
    104

    excel to access

    i keep getting runtime error '13' when i run the DAOexceltoaccess macro

    i have added the reference DAO 3.6 Object Library

    and changed the file names macro looks like this

    Sub DAOFromExcelToAccess()
    ' exports data from the active worksheet to a table in an Access database
    ' this procedure must be edited before use
    Dim db As Database, rs As Recordset, r As Long
    Set db = OpenDatabase("H:\data.mdb")
    ' open the database
    Set rs = db.OpenRecordset("Table1", dbOpenTable)
    ' get all records in a table
    r = 3 ' the start row in the worksheet
    Do While Len(Range("A" & r).Formula) > 0
    ' repeat until first empty cell in column A
    With rs
    .AddNew ' create a new record
    ' add values to each field in the record
    .Fields("name") = Range("A" & r).Value
    ' add more fields if necessary...
    .Update ' stores the new record
    End With
    r = r + 1 ' next row
    Loop
    rs.Close
    Set rs = Nothing
    db.Close
    Set db = Nothing
    End Sub


    can anyone help ????

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    It would help if you could identify which line of the code the macro is failing on. To do this, hit debug when you get the error and look for the line that's highlighted in yellow.
    Martin

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1