Results 1 to 4 of 4

Thread: what is wrong with this?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Washington DC
    Posts
    330

    Question what is wrong with this?

    Access Module


    Public Function ImportData()
    Dim dbs as database
    Dim Rst as recordset
    Dim mysql as string

    Set dbs = Opendatabase(CurrentDb)
    mySql = "Select * from Tbl_GetData"

    Set rst = dbs.openrecordset(mySql) 'error occures here


    Do Until rst.EOF

    dbtype = rst.Fields(4).Value
    filename = rst.Fields(3).Value
    PathName = rst.Fields(2).Value
    TableName = rst.Fields(1).Value

    DoCmd.DeleteObject acTable, TableName
    DoCmd.TransferDatabase acImport, dbtype, PathName, acDefault, filename, TableName, 0, True

    rst.MoveNext

    Loop

    rst.close
    dbs.close

    End Function
    Swoozie
    Somedays you just should not get out of bed.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    Does the query work if you build it in Query Designer? If so, try copying the SQL from there to your code. Not sure if Access requires it, but when you go through the Designer, it appends a semi-colon to the end of the SQL statement (before the last double quote).
    Also, in code I maintain, I don't use:

    Set dbs = Opendatabase(CurrentDb)

    Try just Set dbs = CurrentDB

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Washington DC
    Posts
    330
    I found the error, it was only a typo of course.
    Swoozie
    Somedays you just should not get out of bed.

  4. #4
    Fanatic Member Matt_T_hat's Avatar
    Join Date
    Dec 2001
    Location
    '76 Male Body Evil-Errors: 666
    Posts
    774
    Originally posted by swoozie
    I found the error, it was only a typo of course.
    Always the way
    ?
    'What's this bit for anyway?
    For Jono

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