+ Reply to Thread
Results 1 to 11 of 11

Importing Access table as it is.

  1. #1
    Registered User
    Join Date
    11-23-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    18

    Importing Access table as it is.

    i have posted previously with a similar request , and i am still trying on my own.
    i want to import one table fully from a particular MDB ( access ) file.
    i recorded a macro to that efect which looks like this.
    Please Login or Register  to view this content.
    Now the table extracted by this is "frame section assignments which is what i want.

    but the path of the mdb file is fixed in the above code.
    i want to make it user select or variable as per user so i modified it to the following code.

    Please Login or Register  to view this content.
    but it doesnt work.. it searches for a file named "filename1.mdb"
    and it gives error.
    I Think my mistake lies somewhere in
    DSN and DBQ and Default Directory
    do guide me on this one...
    thanking you all in advance.
    --
    From,
    SSP
    Last edited by sspandit; 11-26-2009 at 01:41 AM.

  2. #2
    Registered User
    Join Date
    11-23-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Importing Access table as it is.

    Please do someone reply.
    for Experts like you i think this little query must be really easy.
    please do guide me.
    thanks again

  3. #3
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Importing Access table as it is.

    You need to change the With ActiveSheet line as shown below
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    11-23-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    18

    Talking Re: Importing Access table as it is.

    Thanks Huron the User Prompt to select filename worked.

    but now it is giving some error at last.

    Run-Time Error '1004'
    general ODBC error.


    Where am i going wrong??

    when i DEBUG it, this line of the code gets highlighted.

    Please Login or Register  to view this content.
    please let me know what little tweak is needed.
    and thanks a million

  5. #5
    Forum Contributor
    Join Date
    09-22-2009
    Location
    Indianapolis, Indiana
    MS-Off Ver
    Office 2003 / Office 2007
    Posts
    114

    Re: Importing Access table as it is.

    Try this. Some of what I am doing I am sure is not exactly proper, but complete documentation on ADO seems a bit lacking. This is much more flexible than trying to use QueryTables and you just use a SQL query. Modify to suit your needs. Please note the query used here will return the ENTIRE TABLE. If it is quite large, you may want to narrow that down some.

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Importing Access table as it is.

    Do the other databases have the same table and field names? The code refers to Frame Section Assignments.Line etc. If the databases are different, this part of the code will need to be changed.

  7. #7
    Registered User
    Join Date
    11-23-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Importing Access table as it is.

    HUron:
    database has the same column headers.
    that is Story , Line , Line Type etc. etc.
    i dont know where exactly the code is going wrong.
    hmm

  8. #8
    Registered User
    Join Date
    11-23-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Importing Access table as it is.

    MARZUK:

    i tried the code which you have given but it gives some error as well...

    it says
    arguments are of the wrong type, are out of acceptable range, or are in conflich with one another

    MARZUK AND HURON:---
    i am attaching the MDB file which i am using.
    all my future mDB files will have the tables having same headers.
    http://www.4shared.com/file/15976772...e1/R1_MDB.html

    hope you help me with this one
    -- SSP

  9. #9
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Importing Access table as it is.

    I think this should work
    Please Login or Register  to view this content.
    I've tried it on your database and it worked for me.

  10. #10
    Registered User
    Join Date
    11-23-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    18

    Re: Importing Access table as it is.

    Thanks a million Huron !!!
    it worked like a charm !!


    i think even i should start learning VBA / Macro from scratch !! its very interesting.

    and thanks a lot again!
    you saved a lot of work.
    -- SSP

    P.S.: can you suggest any good books which might be a good start for a beginner like moi to start learning macro.

  11. #11
    Valued Forum Contributor
    Join Date
    08-23-2009
    Location
    Hampshire, UK
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    328

    Re: Importing Access table as it is.

    I'm glad it worked.

    I can't really recommend any books - I've just learned most of what I know (which isn't very much!) by recording macros and adjusting them afterwards with help from the F1 key and Google.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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